Skip to content

Commit 38e6200

Browse files
committed
fix(test): exit code of lime test -- add proof of current behaviour
1 parent 998e779 commit 38e6200

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/vendor/lime/lime.php

+16-4
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,7 @@ function lime_shutdown()
952952
);
953953

954954
ob_start();
955-
// see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing
956-
passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->php_cli), escapeshellarg($test_file)), $return);
955+
$return = $this->executePhpFile($test_file);
957956
ob_end_clean();
958957
unlink($test_file);
959958

@@ -1123,6 +1122,20 @@ public function get_failed_files()
11231122
{
11241123
return isset($this->stats['failed_files']) ? $this->stats['failed_files'] : array();
11251124
}
1125+
1126+
/**
1127+
* The command fails if the path to php interpreter contains spaces.
1128+
* The only workaround is adding a "nop" command call before the quoted command.
1129+
* The weird "cd &".
1130+
*
1131+
* see http://trac.symfony-project.org/ticket/5437
1132+
*/
1133+
public function executePhpFile(string $phpFile): int
1134+
{
1135+
passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->php_cli), escapeshellarg($phpFile)), $return);
1136+
1137+
return $return;
1138+
}
11261139
}
11271140

11281141
class lime_coverage extends lime_registration
@@ -1186,8 +1199,7 @@ public function process($files)
11861199
EOF;
11871200
file_put_contents($tmp_file, $tmp);
11881201
ob_start();
1189-
// see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing
1190-
passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->harness->php_cli), escapeshellarg($tmp_file)), $return);
1202+
$return = $this->harness->executePhpFile($tmp_file);
11911203
$retval = ob_get_clean();
11921204

11931205
if (0 != $return) // test exited without success

0 commit comments

Comments
 (0)