Skip to content

Commit b24addd

Browse files
authored
run-tests.php: Save STDIN section into a file (#18305)
When a test has an --STDIN-- or --PHPDBG-- section, save the section's content into a file, like we do for the other sections. This makes it bit easier to reproduce these tests outside of run-tests.php. This doesn't update the .sh file to pass the file as stdin to the program, yet. When using gdb, we can pass the file as stdin like this: gdb --args php (gdb) r test.php < test.stdin
1 parent 16c4c06 commit b24addd

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ php
237237
**/tests/**/*.exp
238238
**/tests/**/*.log
239239
**/tests/**/*.sh
240+
**/tests/**/*.stdin
240241

241242
# Generated by some test cases
242243
**/tests/**/*.db

run-tests.php

+12
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,7 @@ function run_test(string $php, $file, array $env): string
19341934
$diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff';
19351935
$log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log';
19361936
$exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
1937+
$stdin_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'stdin';
19371938
$output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
19381939
$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
19391940
$sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh';
@@ -1972,6 +1973,7 @@ function run_test(string $php, $file, array $env): string
19721973
@unlink($diff_filename);
19731974
@unlink($log_filename);
19741975
@unlink($exp_filename);
1976+
@unlink($stdin_filename);
19751977
@unlink($output_filename);
19761978
@unlink($memcheck_filename);
19771979
@unlink($sh_filename);
@@ -2696,6 +2698,16 @@ function run_test(string $php, $file, array $env): string
26962698
$diff = generate_diff($wanted, $wanted_re, $output);
26972699
}
26982700

2701+
// write .stdin
2702+
if ($test->hasSection('STDIN') || $test->hasSection('PHPDBG')) {
2703+
$stdin = $test->hasSection('STDIN')
2704+
? $test->getSection('STDIN')
2705+
: $test->getSection('PHPDBG') . "\n";
2706+
if (file_put_contents($stdin_filename, $stdin) === false) {
2707+
error("Cannot create test stdin - $stdin_filename");
2708+
}
2709+
}
2710+
26992711
if (is_array($IN_REDIRECT)) {
27002712
$orig_shortname = str_replace(TEST_PHP_SRCDIR . '/', '', $file);
27012713
$diff = "# original source file: $orig_shortname\n" . $diff;

0 commit comments

Comments
 (0)