From 4f42a0affbc239a4af06fe7b69a8ba19f97934ca Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 6 Sep 2021 17:58:50 +0100 Subject: [PATCH] Report output from CLEAN (#7456) Mark test as borked if the test passed and CLEAN produces output. Co-authored-by: Nikita Popov --- run-tests.php | 80 +++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/run-tests.php b/run-tests.php index e7df5d69462..200ba5cd26c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2495,6 +2495,8 @@ COMMAND $cmd ]; } + // Remember CLEAN output to report borked test if it otherwise passes. + $clean_output = null; if ($test->sectionNotEmpty('CLEAN') && (!$no_clean || $cfg['keep']['clean'])) { show_file_block('clean', $test->getSection('CLEAN')); save_text($test_clean, trim($test->getSection('CLEAN')), $temp_clean); @@ -2502,7 +2504,7 @@ COMMAND $cmd if (!$no_clean) { $extra = !IS_WINDOWS ? "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; - system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); + $clean_output = system_with_timeout("$extra $orig_php $pass_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env); } if (!$cfg['keep']['clean']) { @@ -2654,25 +2656,6 @@ COMMAND $cmd if (preg_match("/^$wanted_re\$/s", $output)) { $passed = true; - if (!$cfg['keep']['php'] && !$leaked) { - @unlink($test_file); - @unlink($preload_filename); - } - @unlink($tmp_post); - - if (!$leaked && !$failed_headers) { - if ($test->hasSection('XFAIL')) { - $warn = true; - $info = " (warn: XFAIL section but test passes)"; - } elseif ($test->hasSection('XLEAK')) { - $warn = true; - $info = " (warn: XLEAK section but test passes)"; - } else { - show_result("PASS", $tested, $tested_file, '', $temp_filenames); - $junit->markTestAs('PASS', $shortname, $tested); - return 'PASSED'; - } - } } } else { $wanted = trim($test->getSection('EXPECT')); @@ -2682,31 +2665,48 @@ COMMAND $cmd // compare and leave on success if (!strcmp($output, $wanted)) { $passed = true; - - if (!$cfg['keep']['php'] && !$leaked) { - @unlink($test_file); - @unlink($preload_filename); - } - @unlink($tmp_post); - - if (!$leaked && !$failed_headers) { - if ($test->hasSection('XFAIL')) { - $warn = true; - $info = " (warn: XFAIL section but test passes)"; - } elseif ($test->hasSection('XLEAK')) { - $warn = true; - $info = " (warn: XLEAK section but test passes)"; - } else { - show_result("PASS", $tested, $tested_file, '', $temp_filenames); - $junit->markTestAs('PASS', $shortname, $tested); - return 'PASSED'; - } - } } $wanted_re = null; } + if ($passed) { + if (!$cfg['keep']['php'] && !$leaked) { + @unlink($test_file); + @unlink($preload_filename); + } + @unlink($tmp_post); + + if (!$leaked && !$failed_headers) { + // If the test passed and CLEAN produced output, report test as borked. + if ($clean_output) { + show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames); + $PHP_FAILED_TESTS['BORKED'][] = [ + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$clean_output [$file]", + ]; + + $junit->markTestAs('BORK', $shortname, $tested, null, $clean_output); + return 'BORKED'; + } + + if ($test->hasSection('XFAIL')) { + $warn = true; + $info = " (warn: XFAIL section but test passes)"; + } elseif ($test->hasSection('XLEAK')) { + $warn = true; + $info = " (warn: XLEAK section but test passes)"; + } else { + show_result("PASS", $tested, $tested_file, '', $temp_filenames); + $junit->markTestAs('PASS', $shortname, $tested); + return 'PASSED'; + } + } + } + // Test failed so we need to report details. if ($failed_headers) { $passed = false;