Skip to content

Commit

Permalink
Work around failing test cases on Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Nov 6, 2019
1 parent 13e9ff9 commit 09e6e3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Clue/PharComposer/Phar/Packager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ public function exec($cmd, $chdir = null)

$process = new Process($cmd, $chdir);
$process->setTimeout(null);
$process->start();
$code = $process->wait(function($type, $data) use ($output, &$nl) {
$code = $process->run(function($type, $data) use ($output, &$nl) {
if ($nl === true) {
$data = "\n" . $data;
$nl = false;
Expand Down
20 changes: 17 additions & 3 deletions tests/Phar/PackagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,29 @@ public function testExec($expectedOutput, $command)
{
$this->expectOutputString($expectedOutput);

// Travis CI occasionally discards (parts of) the output, so wrap in shell and add some delay just in case
if (getenv('TRAVIS') === 'true') {
$command = 'exec sh -c ' . escapeshellarg($command . '; sleep 0.1');
}

$this->packager->exec($command);
}

public function provideExecCommands()
{
return array(
array("\n output\n", 'echo output'),
array("\n error\n", 'echo error >&2'),
array("\n mixed\n errors\n", 'echo mixed && echo errors >&1'),
array(
"\n output\n",
'echo output'
),
array(
"\n error\n",
'echo error >&2'
),
array(
"\n mixed\n errors\n",
'echo mixed && echo errors >&1'
)
);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Phar/TargetPharTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class TargetPharTest extends TestCase
*/
public function setUp()
{
if (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID <= 50600) {
$this->markTestSkipped('Unable to mock \Phar on PHP 5.4/5.5');
}

$this->mockPhar = $this->createMock('\Phar');
$this->mockBox = $this->createMock('Herrera\Box\Box');
$this->mockBox->expects($this->any())
Expand Down

0 comments on commit 09e6e3f

Please sign in to comment.