diff --git a/.gitignore b/.gitignore index 91120a5fa6b2..55c441323cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -237,6 +237,7 @@ php **/tests/**/*.exp **/tests/**/*.log **/tests/**/*.sh +**/tests/**/*.stdin # Generated by some test cases **/tests/**/*.db diff --git a/run-tests.php b/run-tests.php index 0db6937c7a84..a90681c7ff7f 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1934,6 +1934,7 @@ function run_test(string $php, $file, array $env): string $diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff'; $log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log'; $exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp'; + $stdin_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'stdin'; $output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out'; $memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem'; $sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh'; @@ -1972,6 +1973,7 @@ function run_test(string $php, $file, array $env): string @unlink($diff_filename); @unlink($log_filename); @unlink($exp_filename); + @unlink($stdin_filename); @unlink($output_filename); @unlink($memcheck_filename); @unlink($sh_filename); @@ -2696,6 +2698,16 @@ function run_test(string $php, $file, array $env): string $diff = generate_diff($wanted, $wanted_re, $output); } + // write .stdin + if ($test->hasSection('STDIN') || $test->hasSection('PHPDBG')) { + $stdin = $test->hasSection('STDIN') + ? $test->getSection('STDIN') + : $test->getSection('PHPDBG') . "\n"; + if (file_put_contents($stdin_filename, $stdin) === false) { + error("Cannot create test stdin - $stdin_filename"); + } + } + if (is_array($IN_REDIRECT)) { $orig_shortname = str_replace(TEST_PHP_SRCDIR . '/', '', $file); $diff = "# original source file: $orig_shortname\n" . $diff;