Skip to content

Commit bb51c4b

Browse files
committed
track tests skipped by ext separately
1 parent dd85db4 commit bb51c4b

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

run-tests.php

Lines changed: 37 additions & 18 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
@@ -1773,6 +1773,18 @@ function skip_test(string $tested, string $tested_file, string $shortname, strin
17731773
return 'SKIPPED';
17741774
}
17751775

1776+
function skip_ext_test(string $tested, string $tested_file, string $shortname, array $missing_exts) {
1777+
global $junit;
1778+
1779+
$reason = 'Required extension' . (count($missing_exts) > 1 ? 's' : '')
1780+
. ' missing: ' . implode(', ', $missing_exts);
1781+
1782+
show_result('SKIP_EXT', $tested, $tested_file, "reason: $reason");
1783+
$junit->initSuite($junit->getSuiteName($shortname));
1784+
$junit->markTestAs('SKIP_EXT', $shortname, $tested, 0, $reason);
1785+
return 'SKIPPED_EXT';
1786+
}
1787+
17761788
//
17771789
// Run an individual test case.
17781790
//
@@ -2042,9 +2054,7 @@ function run_test(string $php, $file, array $env): string
20422054
}
20432055
}
20442056
if ($missing) {
2045-
$message = 'Required extension' . (count($missing) > 1 ? 's' : '')
2046-
. ' missing: ' . implode(', ', $missing);
2047-
return skip_test($tested, $tested_file, $shortname, $message);
2057+
return skip_ext_test($tested, $tested_file, $shortname, $missing);
20482058
}
20492059
}
20502060

@@ -3037,6 +3047,7 @@ function compute_summary(): void
30373047
'PASSED' => 0,
30383048
'WARNED' => 0,
30393049
'SKIPPED' => 0,
3050+
'SKIPPED_EXT' => 0,
30403051
'FAILED' => 0,
30413052
'BORKED' => 0,
30423053
'LEAKED' => 0,
@@ -3060,7 +3071,7 @@ function get_summary(bool $show_ext_summary): string
30603071
{
30613072
global $n_total, $sum_results, $percent_results, $end_time, $start_time, $failed_test_summary, $PHP_FAILED_TESTS, $valgrind;
30623073

3063-
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['BORKED'];
3074+
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['SKIPPED_EXT'] - $sum_results['BORKED'];
30643075

30653076
if ($x_total) {
30663077
$x_warned = (100.0 * $sum_results['WARNED']) / $x_total;
@@ -3083,37 +3094,38 @@ function get_summary(bool $show_ext_summary): string
30833094
';
30843095
}
30853096

3086-
$summary .= '
3087-
Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
3097+
$summary .=
3098+
'Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
30883099

30893100
if ($sum_results['BORKED']) {
30903101
$summary .= '
3091-
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
3102+
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
30923103
}
30933104

30943105
$summary .= '
3095-
Tests skipped : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3096-
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3097-
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
3106+
Tests skipped by ext: ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED_EXT'], $percent_results['SKIPPED_EXT']) . ' --------
3107+
Tests skipped other : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3108+
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3109+
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
30983110

30993111
if ($sum_results['XFAILED']) {
31003112
$summary .= '
3101-
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
3113+
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
31023114
}
31033115

31043116
if ($valgrind) {
31053117
$summary .= '
3106-
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
3118+
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
31073119
if ($sum_results['XLEAKED']) {
31083120
$summary .= '
3109-
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
3121+
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
31103122
}
31113123
}
31123124

31133125
$summary .= '
3114-
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
3126+
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
31153127
---------------------------------------------------------------------
3116-
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
3128+
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
31173129
=====================================================================
31183130
';
31193131
$failed_test_summary = '';
@@ -3334,6 +3346,7 @@ class JUnit
33343346
'test_fail' => 0,
33353347
'test_error' => 0,
33363348
'test_skip' => 0,
3349+
'test_skip_ext' => 0,
33373350
'test_warn' => 0,
33383351
'files' => [],
33393352
'execution_time' => 0,
@@ -3374,12 +3387,13 @@ public function saveXML(): void
33743387

33753388
$xml = '<' . '?' . 'xml version="1.0" encoding="UTF-8"' . '?' . '>' . PHP_EOL;
33763389
$xml .= sprintf(
3377-
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3390+
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
33783391
$this->rootSuite['name'],
33793392
$this->rootSuite['test_total'],
33803393
$this->rootSuite['test_fail'],
33813394
$this->rootSuite['test_error'],
33823395
$this->rootSuite['test_skip'],
3396+
$this->rootSuite['test_skip_ext'],
33833397
$this->rootSuite['execution_time']
33843398
);
33853399
$xml .= $this->getSuitesXML();
@@ -3394,12 +3408,13 @@ private function getSuitesXML(string $suite_name = '')
33943408

33953409
foreach ($this->suites as $suite_name => $suite) {
33963410
$result .= sprintf(
3397-
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3411+
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
33983412
$suite['name'],
33993413
$suite['test_total'],
34003414
$suite['test_fail'],
34013415
$suite['test_error'],
34023416
$suite['test_skip'],
3417+
$suite['test_skip_ext'],
34033418
$suite['execution_time']
34043419
);
34053420

@@ -3459,6 +3474,9 @@ public function markTestAs(
34593474
} elseif ('SKIP' == $type) {
34603475
$this->record($suite, 'test_skip');
34613476
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
3477+
} elseif ('SKIP_EXP' == $type) {
3478+
$this->record($suite, 'test_skip_ext');
3479+
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped_ext>$escaped_message</skipped_ext>\n";
34623480
} elseif ('WARN' == $type) {
34633481
$this->record($suite, 'test_warn');
34643482
$this->rootSuite['files'][$file_name]['xml'] .= "<warning>$escaped_message</warning>\n";
@@ -3605,6 +3623,7 @@ private function mergeSuites(array &$dest, array $source): void
36053623
$dest['test_fail'] += $source['test_fail'];
36063624
$dest['test_error'] += $source['test_error'];
36073625
$dest['test_skip'] += $source['test_skip'];
3626+
$dest['test_skip_ext'] += $source['test_skip_ext'];
36083627
$dest['test_warn'] += $source['test_warn'];
36093628
$dest['execution_time'] += $source['execution_time'];
36103629
$dest['files'] += $source['files'];

0 commit comments

Comments
 (0)