Skip to content

Commit e49593a

Browse files
villfanikic
authored andcommitted
Mark test as borked when skipif produces invalid output
SKIPIF section should either output nothing, or start with a supported keyword like "skip". Mark all tests that don't do so as BORKED.
1 parent 235983d commit e49593a

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

run-tests.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,17 +2135,18 @@ function run_test($php, $file, $env)
21352135

21362136
junit_start_timer($shortname);
21372137

2138-
$output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache -d display_errors=0 \"$test_skipif\"", $env);
2138+
$output = system_with_timeout("$extra $php $pass_options $extra_options -q $orig_ini_settings $no_file_cache -d display_errors=1 \"$test_skipif\"", $env);
2139+
$output = trim($output);
21392140

21402141
junit_finish_timer($shortname);
21412142

21422143
if (!$cfg['keep']['skip']) {
21432144
@unlink($test_skipif);
21442145
}
21452146

2146-
if (!strncasecmp('skip', ltrim($output), 4)) {
2147+
if (!strncasecmp('skip', $output, 4)) {
21472148

2148-
if (preg_match('/^\s*skip\s*(.+)\s*/i', $output, $m)) {
2149+
if (preg_match('/^skip\s*(.+)/i', $output, $m)) {
21492150
show_result('SKIP', $tested, $tested_file, "reason: $m[1]", $temp_filenames);
21502151
} else {
21512152
show_result('SKIP', $tested, $tested_file, '', $temp_filenames);
@@ -2160,22 +2161,26 @@ function run_test($php, $file, $env)
21602161
return 'SKIPPED';
21612162
}
21622163

2163-
if (!strncasecmp('info', ltrim($output), 4)) {
2164-
if (preg_match('/^\s*info\s*(.+)\s*/i', $output, $m)) {
2165-
$info = " (info: $m[1])";
2166-
}
2167-
}
2168-
2169-
if (!strncasecmp('warn', ltrim($output), 4)) {
2170-
if (preg_match('/^\s*warn\s*(.+)\s*/i', $output, $m)) {
2171-
$warn = true; /* only if there is a reason */
2172-
$info = " (warn: $m[1])";
2173-
}
2174-
}
2175-
2176-
if (!strncasecmp('xfail', ltrim($output), 5)) {
2164+
if (!strncasecmp('info', $output, 4) && preg_match('/^info\s*(.+)/i', $output, $m)) {
2165+
$info = " (info: $m[1])";
2166+
} elseif (!strncasecmp('warn', $output, 4) && preg_match('/^warn\s*(.+)/i', $output, $m)) {
2167+
$warn = true; /* only if there is a reason */
2168+
$info = " (warn: $m[1])";
2169+
} elseif (!strncasecmp('xfail', $output, 5)) {
21772170
// Pretend we have an XFAIL section
2178-
$section_text['XFAIL'] = trim(substr(ltrim($output), 5));
2171+
$section_text['XFAIL'] = ltrim(substr($output, 5));
2172+
} elseif ($output !== '') {
2173+
show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames);
2174+
$PHP_FAILED_TESTS['BORKED'][] = array(
2175+
'name' => $file,
2176+
'test_name' => '',
2177+
'output' => '',
2178+
'diff' => '',
2179+
'info' => "$output [$file]",
2180+
);
2181+
2182+
junit_mark_test_as('BORK', $shortname, $tested, null, $output);
2183+
return 'BORKED';
21792184
}
21802185
}
21812186
}
@@ -2232,7 +2237,7 @@ function run_test($php, $file, $env)
22322237
} else {
22332238

22342239
$bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory.";
2235-
show_result("BORK", $bork_info, '', $temp_filenames);
2240+
show_result("BORK", $bork_info, '', '', $temp_filenames);
22362241
$PHP_FAILED_TESTS['BORKED'][] = array(
22372242
'name' => $file,
22382243
'test_name' => '',
@@ -2250,7 +2255,7 @@ function run_test($php, $file, $env)
22502255
}
22512256

22522257
$bork_info = "Redirected test did not contain redirection info";
2253-
show_result("BORK", $bork_info, '', $temp_filenames);
2258+
show_result("BORK", $bork_info, '', '', $temp_filenames);
22542259
$PHP_FAILED_TESTS['BORKED'][] = array(
22552260
'name' => $file,
22562261
'test_name' => '',

0 commit comments

Comments
 (0)