Skip to content

Commit

Permalink
[Process] Cleanup tests & prevent assertion that kills randomly Travi…
Browse files Browse the repository at this point in the history
…s-CI
  • Loading branch information
stloyd committed May 6, 2013
1 parent 7deb923 commit 05b987f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 37 deletions.
13 changes: 7 additions & 6 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Expand Up @@ -88,18 +88,21 @@ public function testProcessResponses($expected, $getter, $code)
*
* @dataProvider pipesCodeProvider
*/
public function testProcessPipes($expected, $code)
public function testProcessPipes($code, $size)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
}

$expected = str_repeat(str_repeat('*', 1024), $size) . '!';
$expectedLength = (1024 * $size) + 1;

$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p->setStdin($expected);
$p->run();

$this->assertSame($expected, $p->getOutput());
$this->assertSame($expected, $p->getErrorOutput());
$this->assertEquals($expectedLength, strlen($p->getOutput()));
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
}

public function chainedCommandsOutputProvider()
Expand Down Expand Up @@ -338,13 +341,11 @@ public function pipesCodeProvider()
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
'include \'' . __DIR__ . '/ProcessTestHelper.php\';',
);
$baseData = str_repeat('*', 1024);

$codes = array();
foreach (array(1, 16, 64, 1024, 4096) as $size) {
$data = str_repeat($baseData, $size) . '!';
foreach ($variations as $code) {
$codes[] = array($data, $code);
$codes[] = array($code, $size);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Process/Tests/PhpProcessTest.php
Expand Up @@ -15,7 +15,6 @@

class PhpProcessTest extends \PHPUnit_Framework_TestCase
{

public function testNonBlockingWorks()
{
$expected = 'hello world!';
Expand Down
20 changes: 4 additions & 16 deletions src/Symfony/Component/Process/Tests/ProcessBuilderTest.php
Expand Up @@ -15,10 +15,7 @@

class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldInheritEnvironmentVars()
public function testInheritEnvironmentVars()
{
$snapshot = $_ENV;
$_ENV = $expected = array('foo' => 'bar');
Expand All @@ -32,10 +29,7 @@ public function shouldInheritEnvironmentVars()
$_ENV = $snapshot;
}

/**
* @test
*/
public function shouldInheritAndOverrideEnvironmentVars()
public function testProcessShouldInheritAndOverrideEnvironmentVars()
{
$snapshot = $_ENV;
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
Expand All @@ -51,21 +45,15 @@ public function shouldInheritAndOverrideEnvironmentVars()
$_ENV = $snapshot;
}

/**
* @test
*/
public function shouldInheritEnvironmentVarsByDefault()
public function testInheritEnvironmentVarsByDefault()
{
$pb = new ProcessBuilder();
$proc = $pb->add('foo')->getProcess();

$this->assertNull($proc->getEnv());
}

/**
* @test
*/
public function shouldNotReplaceExplicitlySetVars()
public function testNotReplaceExplicitlySetVars()
{
$snapshot = $_ENV;
$_ENV = array('foo' => 'bar');
Expand Down
Expand Up @@ -37,7 +37,8 @@ public function testProcessFailedExceptionThrowsException()
'\InvalidArgumentException',
'Expected a failed process, but the given process was successful.'
);
$exception = new ProcessFailedException($process);

new ProcessFailedException($process);
}

/**
Expand Down
Expand Up @@ -14,55 +14,55 @@
class SigchildDisabledProcessTest extends AbstractProcessTest
{
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testGetExitCode()
{
parent::testGetExitCode();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testExitCodeCommandFailed()
{
parent::testExitCodeCommandFailed();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsSignaledIfStopped()
{
parent::testProcessIsSignaledIfStopped();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithTermSignal()
{
parent::testProcessWithTermSignal();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsNotSignaled()
{
parent::testProcessIsNotSignaled();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithoutTermSignal()
{
parent::testProcessWithoutTermSignal();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testExitCodeText()
{
Expand All @@ -73,15 +73,15 @@ public function testExitCodeText()
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testIsSuccessful()
{
parent::testIsSuccessful();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testIsNotSuccessful()
{
Expand Down
Expand Up @@ -14,31 +14,31 @@
class SigchildEnabledProcessTest extends AbstractProcessTest
{
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsSignaledIfStopped()
{
parent::testProcessIsSignaledIfStopped();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithTermSignal()
{
parent::testProcessWithTermSignal();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsNotSignaled()
{
parent::testProcessIsNotSignaled();
}

/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithoutTermSignal()
{
Expand Down

0 comments on commit 05b987f

Please sign in to comment.