Skip to content

Commit 2b908c4

Browse files
committed
track tests skipped by ext separately
1 parent 263b426 commit 2b908c4

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

run-tests.php

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function show_usage(): void
6969
with value 'bar').
7070
7171
-g Comma separated list of groups to show during test run
72-
(possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, BORK, WARN, LEAK, REDIRECT).
72+
(possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, SKIP_EXT, BORK, WARN, LEAK, REDIRECT).
7373
7474
-m Test for memory leaks with Valgrind (equivalent to -M memcheck).
7575
@@ -1768,6 +1768,18 @@ function skip_test(string $tested, string $tested_file, string $shortname, strin
17681768
return 'SKIPPED';
17691769
}
17701770

1771+
function skip_ext_test(string $tested, string $tested_file, string $shortname, array $missing_exts) {
1772+
global $junit;
1773+
1774+
$reason = 'Required extension' . (count($missing_exts) > 1 ? 's' : '')
1775+
. ' missing: ' . implode(', ', $missing_exts);
1776+
1777+
show_result('SKIP_EXT', $tested, $tested_file, "reason: $reason");
1778+
$junit->initSuite($junit->getSuiteName($shortname));
1779+
$junit->markTestAs('SKIP_EXT', $shortname, $tested, 0, $reason);
1780+
return 'SKIPPED_EXT';
1781+
}
1782+
17711783
//
17721784
// Run an individual test case.
17731785
//
@@ -2037,9 +2049,7 @@ function run_test(string $php, $file, array $env): string
20372049
}
20382050
}
20392051
if ($missing) {
2040-
$message = 'Required extension' . (count($missing) > 1 ? 's' : '')
2041-
. ' missing: ' . implode(', ', $missing);
2042-
return skip_test($tested, $tested_file, $shortname, $message);
2052+
return skip_ext_test($tested, $tested_file, $shortname, $missing);
20432053
}
20442054
}
20452055

@@ -3031,6 +3041,7 @@ function compute_summary(): void
30313041
'PASSED' => 0,
30323042
'WARNED' => 0,
30333043
'SKIPPED' => 0,
3044+
'SKIPPED_EXT' => 0,
30343045
'FAILED' => 0,
30353046
'BORKED' => 0,
30363047
'LEAKED' => 0,
@@ -3053,7 +3064,7 @@ function get_summary(bool $show_ext_summary): string
30533064
{
30543065
global $n_total, $sum_results, $percent_results, $end_time, $start_time, $failed_test_summary, $PHP_FAILED_TESTS, $valgrind;
30553066

3056-
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['BORKED'];
3067+
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['SKIPPED_EXT'] - $sum_results['BORKED'];
30573068

30583069
if ($x_total) {
30593070
$x_warned = (100.0 * $sum_results['WARNED']) / $x_total;
@@ -3077,36 +3088,37 @@ function get_summary(bool $show_ext_summary): string
30773088
}
30783089

30793090
$summary .=
3080-
'Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
3091+
'Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
30813092

30823093
if ($sum_results['BORKED']) {
30833094
$summary .= '
3084-
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
3095+
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
30853096
}
30863097

30873098
$summary .= '
3088-
Tests skipped : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3089-
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3090-
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
3099+
Tests skipped by ext: ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED_EXT'], $percent_results['SKIPPED_EXT']) . ' --------
3100+
Tests skipped other : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3101+
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3102+
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
30913103

30923104
if ($sum_results['XFAILED']) {
30933105
$summary .= '
3094-
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
3106+
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
30953107
}
30963108

30973109
if ($valgrind) {
30983110
$summary .= '
3099-
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
3111+
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
31003112
if ($sum_results['XLEAKED']) {
31013113
$summary .= '
3102-
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
3114+
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
31033115
}
31043116
}
31053117

31063118
$summary .= '
3107-
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
3119+
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
31083120
---------------------------------------------------------------------
3109-
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
3121+
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
31103122
=====================================================================
31113123
';
31123124
$failed_test_summary = '';
@@ -3327,6 +3339,7 @@ class JUnit
33273339
'test_fail' => 0,
33283340
'test_error' => 0,
33293341
'test_skip' => 0,
3342+
'test_skip_ext' => 0,
33303343
'test_warn' => 0,
33313344
'files' => [],
33323345
'execution_time' => 0,
@@ -3367,12 +3380,13 @@ public function saveXML(): void
33673380

33683381
$xml = '<' . '?' . 'xml version="1.0" encoding="UTF-8"' . '?' . '>' . PHP_EOL;
33693382
$xml .= sprintf(
3370-
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3383+
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
33713384
$this->rootSuite['name'],
33723385
$this->rootSuite['test_total'],
33733386
$this->rootSuite['test_fail'],
33743387
$this->rootSuite['test_error'],
33753388
$this->rootSuite['test_skip'],
3389+
$this->rootSuite['test_skip_ext'],
33763390
$this->rootSuite['execution_time']
33773391
);
33783392
$xml .= $this->getSuitesXML();
@@ -3387,12 +3401,13 @@ private function getSuitesXML(string $suite_name = '')
33873401

33883402
foreach ($this->suites as $suite_name => $suite) {
33893403
$result .= sprintf(
3390-
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3404+
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
33913405
$suite['name'],
33923406
$suite['test_total'],
33933407
$suite['test_fail'],
33943408
$suite['test_error'],
33953409
$suite['test_skip'],
3410+
$suite['test_skip_ext'],
33963411
$suite['execution_time']
33973412
);
33983413

@@ -3452,6 +3467,9 @@ public function markTestAs(
34523467
} elseif ('SKIP' == $type) {
34533468
$this->record($suite, 'test_skip');
34543469
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
3470+
} elseif ('SKIP_EXP' == $type) {
3471+
$this->record($suite, 'test_skip_ext');
3472+
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped_ext>$escaped_message</skipped_ext>\n";
34553473
} elseif ('WARN' == $type) {
34563474
$this->record($suite, 'test_warn');
34573475
$this->rootSuite['files'][$file_name]['xml'] .= "<warning>$escaped_message</warning>\n";
@@ -3598,6 +3616,7 @@ private function mergeSuites(array &$dest, array $source): void
35983616
$dest['test_fail'] += $source['test_fail'];
35993617
$dest['test_error'] += $source['test_error'];
36003618
$dest['test_skip'] += $source['test_skip'];
3619+
$dest['test_skip_ext'] += $source['test_skip_ext'];
36013620
$dest['test_warn'] += $source['test_warn'];
36023621
$dest['execution_time'] += $source['execution_time'];
36033622
$dest['files'] += $source['files'];

0 commit comments

Comments
 (0)