From 38e62003ce638783e259d5881fedb2ca63c9b0b6 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Wed, 10 Apr 2024 00:51:00 +0200 Subject: [PATCH] fix(test): exit code of lime test -- add proof of current behaviour --- lib/vendor/lime/lime.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/vendor/lime/lime.php b/lib/vendor/lime/lime.php index c09016fb2..f3e69df13 100644 --- a/lib/vendor/lime/lime.php +++ b/lib/vendor/lime/lime.php @@ -952,8 +952,7 @@ function lime_shutdown() ); ob_start(); - // see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing - passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->php_cli), escapeshellarg($test_file)), $return); + $return = $this->executePhpFile($test_file); ob_end_clean(); unlink($test_file); @@ -1123,6 +1122,20 @@ public function get_failed_files() { return isset($this->stats['failed_files']) ? $this->stats['failed_files'] : array(); } + + /** + * The command fails if the path to php interpreter contains spaces. + * The only workaround is adding a "nop" command call before the quoted command. + * The weird "cd &". + * + * see http://trac.symfony-project.org/ticket/5437 + */ + public function executePhpFile(string $phpFile): int + { + passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->php_cli), escapeshellarg($phpFile)), $return); + + return $return; + } } class lime_coverage extends lime_registration @@ -1186,8 +1199,7 @@ public function process($files) EOF; file_put_contents($tmp_file, $tmp); ob_start(); - // see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing - passthru(sprintf('cd & %s %s 2>&1', escapeshellarg($this->harness->php_cli), escapeshellarg($tmp_file)), $return); + $return = $this->harness->executePhpFile($tmp_file); $retval = ob_get_clean(); if (0 != $return) // test exited without success