diff --git a/composer.json b/composer.json index ff16a7ae..17c643f3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "require": { "php": ">=8.2 <8.6", - "ext-pcntl": "*", "nikic/php-parser": "5.6.1", "league/climate": "^3.10", "marcj/topsort": "^2.0", @@ -22,5 +21,8 @@ "cs-fix": "php-cs-fixer fix $1", "analyse": "phpstan analyse --memory-limit 512M -l 5 -c phpstan.neon", "rector": "rector process --clear-cache" + }, + "suggest": { + "ext-pcntl": "Required for process control features." } } diff --git a/run-tests.php b/run-tests.php index acae634a..8755bc52 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2461,7 +2461,7 @@ $message return 'FAILED'; } $args = substr($args, strlen(' -- ')); - $cmd = './' . $bin_file . ' ' . $args . $cmdRedirect; + $cmd = (IS_WINDOWS ? '.\\' : './') . $bin_file . ' ' . $args . $cmdRedirect; } else { $content = file_get_contents($test_file); if (preg_match('/function main\(\)/', $content)) { @@ -2667,7 +2667,7 @@ COMMAND $cmd $file = substr($test_file, 0, strlen($test_file) - 4); @unlink($file . '.cc'); @unlink($file . '.cc.o'); - @unlink('./' . $bin_file); + @unlink($bin_file); } } @unlink($tmp_post); @@ -4249,6 +4249,9 @@ function compile_php_file(string $file): string throw new CompilationFailureException('Invalid PHP file'); } $binary_file = str_replace('-', '_', basename($file, '.php')); + if (IS_WINDOWS) { + $binary_file .= '.exe'; + } if (!str_contains($data, 'function main()')) { file_put_contents($file, "&1', $output, $exitCode); + $cmd = $compiler_path; + // On Windows, .php files need to be run through the PHP interpreter + if (IS_WINDOWS && str_ends_with($cmd, '.php')) { + $cmd = escapeshellarg(PHP_BINARY) . ' ' . $cmd; + } + exec($cmd . ' ' . escapeshellarg($file) . ' 2>&1', $output, $exitCode); clearstatcache(true, $binary_file); if ($exitCode !== 0 || !file_exists($binary_file)) {