Skip to content

Commit

Permalink
kill process after test is over
Browse files Browse the repository at this point in the history
  • Loading branch information
Reasno committed Mar 27, 2020
1 parent b904a01 commit 3b77228
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/LocalGoTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ private function start()
} catch (\Throwable $e){
$returnChannel->push($e);
}


}
}
}
17 changes: 11 additions & 6 deletions tests/Cases/CoroutineSocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,28 @@
class CoroutineSocketTest extends AbstractTestCase
{
const UNIX_SOCKET = '/tmp/test.sock';

/**
* @var RPC
* @var Process
*/
private $task;
private $p;

public function setUp()
{
! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
@unlink(self::UNIX_SOCKET);
$p = new Process(function (Process $process) {
$process->exec(__DIR__ . '/../../app', ['-address', self::UNIX_SOCKET, '-standalone']);
$this->p = new Process(function (Process $process) {
$process->exec(__DIR__ . '/../../app', ['-address', self::UNIX_SOCKET]);
});
$p->start();
$this->p->start();
sleep(1);
}

public function tearDown()
{
Process::kill($this->p->pid);
}


public function testOnCoroutine()
{
\Swoole\Coroutine\run(function () {
Expand Down
5 changes: 5 additions & 0 deletions tests/Cases/IPCRelayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function setUp()
sleep(1);
}

public function tearDown()
{
Process::kill($this->p->pid);
}

public function testOnCoroutine()
{
\Swoole\Coroutine\run(function () {
Expand Down

0 comments on commit 3b77228

Please sign in to comment.