Skip to content

Commit

Permalink
Use Rust FFI: Offload process
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed May 6, 2023
1 parent 97eb3d1 commit 8b30579
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 505 deletions.
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@
],
"require": {
"php": "^8.0",
"ext-openssl": "*",
"ext-json": "*",
"composer/semver": "^1.4.0|^3.2.0",
"amphp/amp": "^2.5.1",
"amphp/byte-stream": "^1.8",
"amphp/log": "^1.1",
"amphp/process": "^1.1.1",
"symfony/process": "^4.4|^5.4|^6.0",
"guzzlehttp/guzzle": "^6.5.8|^7.4.5",
"phpunit/phpunit": ">=8.5.23 <10",
"tienvx/composer-downloads-plugin": "^1.2.0"
Expand Down
14 changes: 7 additions & 7 deletions example/tests/Provider/PactVerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
use PhpPact\Standalone\ProviderVerifier\Model\Config\ProviderTransport;
use PhpPact\Standalone\ProviderVerifier\Model\VerifierConfig;
use PhpPact\Standalone\ProviderVerifier\Verifier;
use PhpPact\Standalone\Runner\ProcessRunner;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

/**
* This is an example on how you could use the included amphp/process wrapper to start your API to run PACT verification against a Provider.
* Class PactVerifyTest
*/
class PactVerifyTest extends TestCase
{
/** @var ProcessRunner */
private ProcessRunner $processRunner;
/** @var Process */
private Process $process;

/**
* Run the PHP build-in web server.
Expand All @@ -25,18 +25,18 @@ protected function setUp(): void
{
$publicPath = __DIR__ . '/../../src/Provider/public/';

$this->processRunner = new ProcessRunner('php', ['-S', 'localhost:7202', '-t', $publicPath, $publicPath . 'proxy.php']);
$this->process = new Process(['php', '-S', 'localhost:7202', '-t', $publicPath, $publicPath . 'proxy.php']);

$this->processRunner->run();
\sleep(1); // wait for server to start
$this->process->start();
$this->process->waitUntil(fn () => is_resource(@fsockopen('localhost', 7202)));
}

/**
* Stop the web server process once complete.
*/
protected function tearDown(): void
{
$this->processRunner->stop();
$this->process->stop();
}

/**
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ parameters:
level: 7
paths:
- src
ignoreErrors:
-
messages:
- '#Method PhpPact\\Standalone\\Broker\\Broker::[a-zA-Z0-9\\_]+\(\) return type has no value type specified in iterable type array\.#'
- '#Method PhpPact\\Standalone\\Broker\\Broker::[a-zA-Z0-9\\_]+\(\) has parameter \$options with no value type specified in iterable type array\.#'
path: src/PhpPact/Standalone/Broker/Broker.php
Loading

0 comments on commit 8b30579

Please sign in to comment.