Skip to content

Commit 7a28b68

Browse files
committed
copy run-tests.php from master
1 parent 9291de3 commit 7a28b68

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

run-tests.php

+44-39
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,9 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false)
10991099
}
11001100

11011101
// Otherwise we're only interested in *.phpt files.
1102-
if (substr($name, -5) == '.phpt') {
1102+
// (but not those starting with a dot, which are hidden on
1103+
// many platforms)
1104+
if (substr($name, -5) == '.phpt' && substr($name, 0, 1) !== '.') {
11031105
if ($ignore) {
11041106
$ignored_by_ext++;
11051107
} else {
@@ -2507,14 +2509,16 @@ function run_test(string $php, $file, array $env): string
25072509
];
25082510
}
25092511

2512+
// Remember CLEAN output to report borked test if it otherwise passes.
2513+
$clean_output = null;
25102514
if ($test->sectionNotEmpty('CLEAN') && (!$no_clean || $cfg['keep']['clean'])) {
25112515
show_file_block('clean', $test->getSection('CLEAN'));
25122516
save_text($test_clean, trim($test->getSection('CLEAN')), $temp_clean);
25132517

25142518
if (!$no_clean) {
25152519
$extra = !IS_WINDOWS ?
25162520
"unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : "";
2517-
system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env);
2521+
$clean_output = system_with_timeout("$extra $orig_php $pass_options -q $orig_ini_settings $no_file_cache \"$test_clean\"", $env);
25182522
}
25192523

25202524
if (!$cfg['keep']['clean']) {
@@ -2666,25 +2670,6 @@ function run_test(string $php, $file, array $env): string
26662670

26672671
if (preg_match("/^$wanted_re\$/s", $output)) {
26682672
$passed = true;
2669-
if (!$cfg['keep']['php'] && !$leaked) {
2670-
@unlink($test_file);
2671-
@unlink($preload_filename);
2672-
}
2673-
@unlink($tmp_post);
2674-
2675-
if (!$leaked && !$failed_headers) {
2676-
if ($test->hasSection('XFAIL')) {
2677-
$warn = true;
2678-
$info = " (warn: XFAIL section but test passes)";
2679-
} elseif ($test->hasSection('XLEAK')) {
2680-
$warn = true;
2681-
$info = " (warn: XLEAK section but test passes)";
2682-
} else {
2683-
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2684-
$junit->markTestAs('PASS', $shortname, $tested);
2685-
return 'PASSED';
2686-
}
2687-
}
26882673
}
26892674
} else {
26902675
$wanted = trim($test->getSection('EXPECT'));
@@ -2694,29 +2679,46 @@ function run_test(string $php, $file, array $env): string
26942679
// compare and leave on success
26952680
if (!strcmp($output, $wanted)) {
26962681
$passed = true;
2682+
}
2683+
2684+
$wanted_re = null;
2685+
}
2686+
2687+
if ($passed) {
2688+
if (!$cfg['keep']['php'] && !$leaked) {
2689+
@unlink($test_file);
2690+
@unlink($preload_filename);
2691+
}
2692+
@unlink($tmp_post);
2693+
2694+
if (!$leaked && !$failed_headers) {
2695+
// If the test passed and CLEAN produced output, report test as borked.
2696+
if ($clean_output) {
2697+
show_result("BORK", $output, $tested_file, 'reason: invalid output from CLEAN', $temp_filenames);
2698+
$PHP_FAILED_TESTS['BORKED'][] = [
2699+
'name' => $file,
2700+
'test_name' => '',
2701+
'output' => '',
2702+
'diff' => '',
2703+
'info' => "$clean_output [$file]",
2704+
];
26972705

2698-
if (!$cfg['keep']['php'] && !$leaked) {
2699-
@unlink($test_file);
2700-
@unlink($preload_filename);
2706+
$junit->markTestAs('BORK', $shortname, $tested, null, $clean_output);
2707+
return 'BORKED';
27012708
}
2702-
@unlink($tmp_post);
27032709

2704-
if (!$leaked && !$failed_headers) {
2705-
if ($test->hasSection('XFAIL')) {
2706-
$warn = true;
2707-
$info = " (warn: XFAIL section but test passes)";
2708-
} elseif ($test->hasSection('XLEAK')) {
2709-
$warn = true;
2710-
$info = " (warn: XLEAK section but test passes)";
2711-
} else {
2712-
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2713-
$junit->markTestAs('PASS', $shortname, $tested);
2714-
return 'PASSED';
2715-
}
2710+
if ($test->hasSection('XFAIL')) {
2711+
$warn = true;
2712+
$info = " (warn: XFAIL section but test passes)";
2713+
} elseif ($test->hasSection('XLEAK')) {
2714+
$warn = true;
2715+
$info = " (warn: XLEAK section but test passes)";
2716+
} else {
2717+
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
2718+
$junit->markTestAs('PASS', $shortname, $tested);
2719+
return 'PASSED';
27162720
}
27172721
}
2718-
2719-
$wanted_re = null;
27202722
}
27212723

27222724
// Test failed so we need to report details.
@@ -2801,6 +2803,9 @@ function run_test(string $php, $file, array $env): string
28012803
"gdb")
28022804
gdb --args {$orig_cmd}
28032805
;;
2806+
"lldb")
2807+
lldb -- {$orig_cmd}
2808+
;;
28042809
"valgrind")
28052810
USE_ZEND_ALLOC=0 valgrind $2 ${orig_cmd}
28062811
;;

0 commit comments

Comments
 (0)