mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -237,6 +237,7 @@ php
|
||||
**/tests/**/*.exp
|
||||
**/tests/**/*.log
|
||||
**/tests/**/*.sh
|
||||
**/tests/**/*.stdin
|
||||
|
||||
# Generated by some test cases
|
||||
**/tests/**/*.db
|
||||
|
||||
@@ -1934,6 +1934,7 @@ TEST $file
|
||||
$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 @@ TEST $file
|
||||
@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 @@ COMMAND $cmd
|
||||
$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;
|
||||
|
||||
Reference in New Issue
Block a user