Skip to content

Commit

Permalink
remove auto destruct, and local code coverage build, update signal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 29, 2020
1 parent 8fc6030 commit bd628c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 0 additions & 5 deletions Spawn/Launcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ private function __construct(
self::$launcher[$id] = $this;
}

public function __destruct()
{
$this->close();
}

public static function create(Process $process, int $id, int $timeout = 0, bool $isYield = false): LauncherInterface
{
return new self($process, $id, $timeout, null, null, null, null, null, $isYield);
Expand Down
7 changes: 0 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,4 @@
</exclude>
</whitelist>
</filter>

<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
23 changes: 23 additions & 0 deletions tests/SpawnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,29 @@ public function testSignal()
$this->assertEquals(\SIGKILL, $process->getSignaled());
}

public function testSignalYield()
{
$counter = 0;

$process = Spawn::create(function () {
\sleep(10);
}, 0, null, true)->signal(\SIGKILL, function () use (&$counter) {
$counter += 1;
});

$process->stop();
$this->assertTrue($process->isRunning());
$yield = $process->yielding();
$this->assertTrue($yield instanceof \Generator);
$this->assertNull($yield->current());
$this->assertFalse($process->isRunning());
$this->assertFalse($process->isSuccessful());
$this->assertTrue($process->isTerminated());
$this->assertTrue($process->isSignaled());
//$this->assertEquals(1, $counter);
$this->assertEquals(\SIGKILL, $process->getSignaled());
}

public function testIsSuccessfulCMD()
{
$process = Spawn::create('echo foo');
Expand Down

0 comments on commit bd628c1

Please sign in to comment.