[Process] Remove unreachable code + avoid skipping tests in sigchild environment
This commit is contained in:
parent
fccf8b509a
commit
d52dd32bad
@ -323,10 +323,6 @@ class Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->processInformation['signaled']) {
|
if ($this->processInformation['signaled']) {
|
||||||
if ($this->isSigchildEnabled()) {
|
|
||||||
throw new RuntimeException('The process has been signaled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
|
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1184,7 @@ class Process
|
|||||||
|
|
||||||
if (true !== @proc_terminate($this->process, $signal)) {
|
if (true !== @proc_terminate($this->process, $signal)) {
|
||||||
if ($throwException) {
|
if ($throwException) {
|
||||||
throw new RuntimeException(sprintf('Error while sending signal `%d`.', $signal));
|
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,106 +27,123 @@ class SimpleProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
public function testGetExitCode()
|
public function testGetExitCode()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
|
||||||
parent::testGetExitCode();
|
parent::testGetExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExitCodeCommandFailed()
|
public function testExitCodeCommandFailed()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
|
||||||
parent::testExitCodeCommandFailed();
|
parent::testExitCodeCommandFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessIsSignaledIfStopped()
|
public function testProcessIsSignaledIfStopped()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
||||||
parent::testProcessIsSignaledIfStopped();
|
parent::testProcessIsSignaledIfStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessWithTermSignal()
|
public function testProcessWithTermSignal()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
||||||
parent::testProcessWithTermSignal();
|
parent::testProcessWithTermSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessIsNotSignaled()
|
public function testProcessIsNotSignaled()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
||||||
parent::testProcessIsNotSignaled();
|
parent::testProcessIsNotSignaled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessWithoutTermSignal()
|
public function testProcessWithoutTermSignal()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
||||||
parent::testProcessWithoutTermSignal();
|
parent::testProcessWithoutTermSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExitCodeText()
|
public function testExitCodeText()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
|
||||||
parent::testExitCodeText();
|
parent::testExitCodeText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsSuccessful()
|
public function testIsSuccessful()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
parent::testIsSuccessful();
|
parent::testIsSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsNotSuccessful()
|
public function testIsNotSuccessful()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
parent::testIsNotSuccessful();
|
parent::testIsNotSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPid()
|
public function testGetPid()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
parent::testGetPid();
|
parent::testGetPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPidIsNullBeforeStart()
|
public function testGetPidIsNullBeforeStart()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
parent::testGetPidIsNullBeforeStart();
|
parent::testGetPidIsNullBeforeStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPidIsNullAfterRun()
|
public function testGetPidIsNullAfterRun()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
parent::testGetPidIsNullAfterRun();
|
parent::testGetPidIsNullAfterRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSignal()
|
public function testSignal()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
|
||||||
parent::testSignal();
|
parent::testSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
{
|
||||||
*/
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
||||||
|
parent::testProcessWithoutTermSignalIsNotSignaled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||||
|
{
|
||||||
|
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
|
||||||
|
parent::testProcessThrowsExceptionWhenExternallySignaled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testExitCodeIsAvailableAfterSignal()
|
||||||
|
{
|
||||||
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
|
||||||
|
parent::testExitCodeIsAvailableAfterSignal();
|
||||||
|
}
|
||||||
|
|
||||||
public function testSignalProcessNotRunning()
|
public function testSignalProcessNotRunning()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.');
|
||||||
parent::testSignalProcessNotRunning();
|
parent::testSignalProcessNotRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
|
||||||
*/
|
|
||||||
public function testSignalWithWrongIntSignal()
|
public function testSignalWithWrongIntSignal()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
if ($this->enabledSigchild) {
|
||||||
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `-4`.');
|
||||||
|
}
|
||||||
parent::testSignalWithWrongIntSignal();
|
parent::testSignalWithWrongIntSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
|
||||||
*/
|
|
||||||
public function testSignalWithWrongNonIntSignal()
|
public function testSignalWithWrongNonIntSignal()
|
||||||
{
|
{
|
||||||
$this->skipIfPHPSigchild();
|
if ($this->enabledSigchild) {
|
||||||
|
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `Céphalopodes`.');
|
||||||
|
}
|
||||||
parent::testSignalWithWrongNonIntSignal();
|
parent::testSignalWithWrongNonIntSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,4 +161,11 @@ class SimpleProcessTest extends AbstractProcessTest
|
|||||||
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function expectExceptionIfPHPSigchild($classname, $message)
|
||||||
|
{
|
||||||
|
if ($this->enabledSigchild) {
|
||||||
|
$this->setExpectedException($classname, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user