[Process] Make process tests more accurate on exception messages
This commit is contained in:
parent
0738f8387d
commit
1b1768aced
@ -448,7 +448,7 @@ class Process
|
|||||||
public function getExitCode()
|
public function getExitCode()
|
||||||
{
|
{
|
||||||
if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) {
|
if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) {
|
||||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method');
|
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateStatus(false);
|
$this->updateStatus(false);
|
||||||
@ -500,7 +500,7 @@ class Process
|
|||||||
public function hasBeenSignaled()
|
public function hasBeenSignaled()
|
||||||
{
|
{
|
||||||
if ($this->isSigchildEnabled()) {
|
if ($this->isSigchildEnabled()) {
|
||||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateStatus(false);
|
$this->updateStatus(false);
|
||||||
@ -522,7 +522,7 @@ class Process
|
|||||||
public function getTermSignal()
|
public function getTermSignal()
|
||||||
{
|
{
|
||||||
if ($this->isSigchildEnabled()) {
|
if ($this->isSigchildEnabled()) {
|
||||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
|
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateStatus(false);
|
$this->updateStatus(false);
|
||||||
|
@ -256,11 +256,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testStartIsNonBlocking()
|
public function testStartIsNonBlocking()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('php -r "sleep(4);"');
|
$process = $this->getProcess('php -r "usleep(500000);"');
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$process->start();
|
$process->start();
|
||||||
$end = microtime(true);
|
$end = microtime(true);
|
||||||
$this->assertLessThan(1 , $end-$start);
|
$this->assertLessThan(0.2, $end-$start);
|
||||||
|
$process->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateStatus()
|
public function testUpdateStatus()
|
||||||
@ -347,10 +348,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsNotSuccessful()
|
public function testIsNotSuccessful()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('php -r "sleep(4);"');
|
$process = $this->getProcess('php -r "usleep(500000);throw new \Exception(\'BOUM\');"');
|
||||||
$process->start();
|
$process->start();
|
||||||
$this->assertTrue($process->isRunning());
|
$this->assertTrue($process->isRunning());
|
||||||
$process->stop();
|
$process->wait();
|
||||||
$this->assertFalse($process->isSuccessful());
|
$this->assertFalse($process->isSuccessful());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,7 +469,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRunProcessWithTimeout()
|
public function testRunProcessWithTimeout()
|
||||||
{
|
{
|
||||||
$timeout = 0.5;
|
$timeout = 0.5;
|
||||||
$process = $this->getProcess('php -r "sleep(3);"');
|
$process = $this->getProcess('php -r "usleep(600000);"');
|
||||||
$process->setTimeout($timeout);
|
$process->setTimeout($timeout);
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
try {
|
try {
|
||||||
@ -509,7 +510,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testStartAfterATimeout()
|
public function testStartAfterATimeout()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('php -r "while (true) {echo \'\'; usleep(1000); }"');
|
$process = $this->getProcess('php -r "$n = 1000; while ($n--) {echo \'\'; usleep(1000); }"');
|
||||||
$process->setTimeout(0.1);
|
$process->setTimeout(0.1);
|
||||||
try {
|
try {
|
||||||
$process->run();
|
$process->run();
|
||||||
@ -524,10 +525,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetPid()
|
public function testGetPid()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('php -r "sleep(1);"');
|
$process = $this->getProcess('php -r "usleep(500000);"');
|
||||||
$process->start();
|
$process->start();
|
||||||
$this->assertGreaterThan(0, $process->getPid());
|
$this->assertGreaterThan(0, $process->getPid());
|
||||||
$process->stop();
|
$process->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPidIsNullBeforeStart()
|
public function testGetPidIsNullBeforeStart()
|
||||||
|
@ -15,6 +15,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testGetExitCode()
|
public function testGetExitCode()
|
||||||
{
|
{
|
||||||
@ -23,6 +24,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testGetExitCodeIsNullOnStart()
|
public function testGetExitCodeIsNullOnStart()
|
||||||
{
|
{
|
||||||
@ -31,6 +33,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||||
{
|
{
|
||||||
@ -39,6 +42,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testExitCodeCommandFailed()
|
public function testExitCodeCommandFailed()
|
||||||
{
|
{
|
||||||
@ -47,6 +51,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessIsSignaledIfStopped()
|
public function testProcessIsSignaledIfStopped()
|
||||||
{
|
{
|
||||||
@ -55,6 +60,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithTermSignal()
|
public function testProcessWithTermSignal()
|
||||||
{
|
{
|
||||||
@ -63,6 +69,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessIsNotSignaled()
|
public function testProcessIsNotSignaled()
|
||||||
{
|
{
|
||||||
@ -71,6 +78,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignal()
|
public function testProcessWithoutTermSignal()
|
||||||
{
|
{
|
||||||
@ -79,6 +87,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testCheckTimeoutOnStartedProcess()
|
public function testCheckTimeoutOnStartedProcess()
|
||||||
{
|
{
|
||||||
@ -87,6 +96,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPid()
|
public function testGetPid()
|
||||||
{
|
{
|
||||||
@ -95,6 +105,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPidIsNullBeforeStart()
|
public function testGetPidIsNullBeforeStart()
|
||||||
{
|
{
|
||||||
@ -103,6 +114,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPidIsNullAfterRun()
|
public function testGetPidIsNullAfterRun()
|
||||||
{
|
{
|
||||||
@ -111,6 +123,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testExitCodeText()
|
public function testExitCodeText()
|
||||||
{
|
{
|
||||||
@ -122,6 +135,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testIsSuccessful()
|
public function testIsSuccessful()
|
||||||
{
|
{
|
||||||
@ -130,6 +144,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testIsSuccessfulOnlyAfterTerminated()
|
public function testIsSuccessfulOnlyAfterTerminated()
|
||||||
{
|
{
|
||||||
@ -138,6 +153,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testIsNotSuccessful()
|
public function testIsNotSuccessful()
|
||||||
{
|
{
|
||||||
@ -146,6 +162,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
|
||||||
*/
|
*/
|
||||||
public function testTTYCommandExitCode()
|
public function testTTYCommandExitCode()
|
||||||
{
|
{
|
||||||
@ -154,6 +171,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process can not be signaled.
|
||||||
*/
|
*/
|
||||||
public function testSignal()
|
public function testSignal()
|
||||||
{
|
{
|
||||||
@ -162,6 +180,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessIsSignaledIfStopped()
|
public function testProcessIsSignaledIfStopped()
|
||||||
{
|
{
|
||||||
@ -23,6 +24,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithTermSignal()
|
public function testProcessWithTermSignal()
|
||||||
{
|
{
|
||||||
@ -31,6 +33,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessIsNotSignaled()
|
public function testProcessIsNotSignaled()
|
||||||
{
|
{
|
||||||
@ -39,6 +42,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignal()
|
public function testProcessWithoutTermSignal()
|
||||||
{
|
{
|
||||||
@ -47,6 +51,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPid()
|
public function testGetPid()
|
||||||
{
|
{
|
||||||
@ -55,6 +60,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPidIsNullBeforeStart()
|
public function testGetPidIsNullBeforeStart()
|
||||||
{
|
{
|
||||||
@ -63,6 +69,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testGetPidIsNullAfterRun()
|
public function testGetPidIsNullAfterRun()
|
||||||
{
|
{
|
||||||
@ -79,6 +86,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process can not be signaled.
|
||||||
*/
|
*/
|
||||||
public function testSignal()
|
public function testSignal()
|
||||||
{
|
{
|
||||||
@ -87,6 +95,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user