Skip to content

Commit 4f42a0a

Browse files
kamil-tekielanikic
andauthored
Report output from CLEAN (#7456)
Mark test as borked if the test passed and CLEAN produces output. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
1 parent e435613 commit 4f42a0a

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

run-tests.php

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,14 +2495,16 @@ function run_test(string $php, $file, array $env): string
24952495
];
24962496
}
24972497

2498+
// Remember CLEAN output to report borked test if it otherwise passes.
2499+
$clean_output = null;
24982500
if ($test->sectionNotEmpty('CLEAN') && (!$no_clean || $cfg['keep']['clean'])) {
24992501
show_file_block('clean', $test->getSection('CLEAN'));
25002502
save_text($test_clean, trim($test->getSection('CLEAN')), $temp_clean);
25012503

25022504
if (!$no_clean) {
25032505
$extra = !IS_WINDOWS ?
25042506
"unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : "";
2505-
system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env);
2507+
$clean_output = system_with_timeout("$extra $orig_php $pass_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env);
25062508
}
25072509

25082510
if (!$cfg['keep']['clean']) {
@@ -2654,25 +2656,6 @@ function run_test(string $php, $file, array $env): string
26542656

26552657
if (preg_match("/^$wanted_re\$/s", $output)) {
26562658
$passed = true;
2657-
if (!$cfg['keep']['php'] && !$leaked) {
2658-
@unlink($test_file);
2659-
@unlink($preload_filename);
2660-
}
2661-
@unlink($tmp_post);
2662-
2663-
if (!$leaked && !$failed_headers) {
2664-
if ($test->hasSection('XFAIL')) {
2665-
$warn = true;
2666-
$info = " (warn: XFAIL section but test passes)";
2667-
} elseif ($test->hasSection('XLEAK')) {
2668-
$warn = true;
2669-
$info = " (warn: XLEAK section but test passes)";
2670-
} else {
2671-
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2672-
$junit->markTestAs('PASS', $shortname, $tested);
2673-
return 'PASSED';
2674-
}
2675-
}
26762659
}
26772660
} else {
26782661
$wanted = trim($test->getSection('EXPECT'));
@@ -2682,29 +2665,46 @@ function run_test(string $php, $file, array $env): string
26822665
// compare and leave on success
26832666
if (!strcmp($output, $wanted)) {
26842667
$passed = true;
2668+
}
26852669

2686-
if (!$cfg['keep']['php'] && !$leaked) {
2687-
@unlink($test_file);
2688-
@unlink($preload_filename);
2670+
$wanted_re = null;
2671+
}
2672+
2673+
if ($passed) {
2674+
if (!$cfg['keep']['php'] && !$leaked) {
2675+
@unlink($test_file);
2676+
@unlink($preload_filename);
2677+
}
2678+
@unlink($tmp_post);
2679+
2680+
if (!$leaked && !$failed_headers) {
2681+
// If the test passed and CLEAN produced output, report test as borked.
2682+
if ($clean_output) {
2683+
show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames);
2684+
$PHP_FAILED_TESTS['BORKED'][] = [
2685+
'name' => $file,
2686+
'test_name' => '',
2687+
'output' => '',
2688+
'diff' => '',
2689+
'info' => "$clean_output [$file]",
2690+
];
2691+
2692+
$junit->markTestAs('BORK', $shortname, $tested, null, $clean_output);
2693+
return 'BORKED';
26892694
}
2690-
@unlink($tmp_post);
26912695

2692-
if (!$leaked && !$failed_headers) {
2693-
if ($test->hasSection('XFAIL')) {
2694-
$warn = true;
2695-
$info = " (warn: XFAIL section but test passes)";
2696-
} elseif ($test->hasSection('XLEAK')) {
2697-
$warn = true;
2698-
$info = " (warn: XLEAK section but test passes)";
2699-
} else {
2700-
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2701-
$junit->markTestAs('PASS', $shortname, $tested);
2702-
return 'PASSED';
2703-
}
2696+
if ($test->hasSection('XFAIL')) {
2697+
$warn = true;
2698+
$info = " (warn: XFAIL section but test passes)";
2699+
} elseif ($test->hasSection('XLEAK')) {
2700+
$warn = true;
2701+
$info = " (warn: XLEAK section but test passes)";
2702+
} else {
2703+
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2704+
$junit->markTestAs('PASS', $shortname, $tested);
2705+
return 'PASSED';
27042706
}
27052707
}
2706-
2707-
$wanted_re = null;
27082708
}
27092709

27102710
// Test failed so we need to report details.

0 commit comments

Comments
 (0)