Skip to content

Commit 24cb772

Browse files
committed
track tests skipped by ext separately
1 parent 5cf1385 commit 24cb772

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
@@ -1850,6 +1850,18 @@ function skip_test(string $tested, string $tested_file, string $shortname, strin
18501850
return 'SKIPPED';
18511851
}
18521852

1853+
function skip_ext_test(string $tested, string $tested_file, string $shortname, array $missing_exts) {
1854+
global $junit;
1855+
1856+
$reason = 'Required extension' . (count($missing_exts) > 1 ? 's' : '')
1857+
. ' missing: ' . implode(', ', $missing_exts);
1858+
1859+
show_result('SKIP_EXT', $tested, $tested_file, "reason: $reason");
1860+
$junit->initSuite($junit->getSuiteName($shortname));
1861+
$junit->markTestAs('SKIP_EXT', $shortname, $tested, 0, $reason);
1862+
return 'SKIPPED_EXT';
1863+
}
1864+
18531865
//
18541866
// Run an individual test case.
18551867
//
@@ -2115,9 +2127,7 @@ function run_test(string $php, $file, array $env): string
21152127
}
21162128
}
21172129
if ($missing) {
2118-
$message = 'Required extension' . (count($missing) > 1 ? 's' : '')
2119-
. ' missing: ' . implode(', ', $missing);
2120-
return skip_test($tested, $tested_file, $shortname, $message);
2130+
return skip_ext_test($tested, $tested_file, $shortname, $missing);
21212131
}
21222132
}
21232133

@@ -3098,6 +3108,7 @@ function compute_summary(): void
30983108
'PASSED' => 0,
30993109
'WARNED' => 0,
31003110
'SKIPPED' => 0,
3111+
'SKIPPED_EXT' => 0,
31013112
'FAILED' => 0,
31023113
'BORKED' => 0,
31033114
'LEAKED' => 0,
@@ -3120,7 +3131,7 @@ function get_summary(bool $show_ext_summary): string
31203131
{
31213132
global $n_total, $sum_results, $percent_results, $end_time, $start_time, $failed_test_summary, $PHP_FAILED_TESTS, $valgrind;
31223133

3123-
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['BORKED'];
3134+
$x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['SKIPPED_EXT'] - $sum_results['BORKED'];
31243135

31253136
if ($x_total) {
31263137
$x_warned = (100.0 * $sum_results['WARNED']) / $x_total;
@@ -3144,36 +3155,37 @@ function get_summary(bool $show_ext_summary): string
31443155
}
31453156

31463157
$summary .=
3147-
'Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
3158+
'Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
31483159

31493160
if ($sum_results['BORKED']) {
31503161
$summary .= '
3151-
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
3162+
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
31523163
}
31533164

31543165
$summary .= '
3155-
Tests skipped : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3156-
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3157-
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
3166+
Tests skipped by ext: ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED_EXT'], $percent_results['SKIPPED_EXT']) . ' --------
3167+
Tests skipped other : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
3168+
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
3169+
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
31583170

31593171
if ($sum_results['XFAILED']) {
31603172
$summary .= '
3161-
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
3173+
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
31623174
}
31633175

31643176
if ($valgrind) {
31653177
$summary .= '
3166-
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
3178+
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
31673179
if ($sum_results['XLEAKED']) {
31683180
$summary .= '
3169-
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
3181+
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
31703182
}
31713183
}
31723184

31733185
$summary .= '
3174-
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
3186+
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
31753187
---------------------------------------------------------------------
3176-
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
3188+
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
31773189
=====================================================================
31783190
';
31793191
$failed_test_summary = '';
@@ -3395,6 +3407,7 @@ class JUnit
33953407
'test_fail' => 0,
33963408
'test_error' => 0,
33973409
'test_skip' => 0,
3410+
'test_skip_ext' => 0,
33983411
'test_warn' => 0,
33993412
'files' => [],
34003413
'execution_time' => 0,
@@ -3432,12 +3445,13 @@ public function saveXML(): void
34323445

34333446
$xml = '<' . '?' . 'xml version="1.0" encoding="UTF-8"' . '?' . '>' . PHP_EOL;
34343447
$xml .= sprintf(
3435-
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3448+
'<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
34363449
$this->rootSuite['name'],
34373450
$this->rootSuite['test_total'],
34383451
$this->rootSuite['test_fail'],
34393452
$this->rootSuite['test_error'],
34403453
$this->rootSuite['test_skip'],
3454+
$this->rootSuite['test_skip_ext'],
34413455
$this->rootSuite['execution_time']
34423456
);
34433457
$xml .= $this->getSuitesXML();
@@ -3452,12 +3466,13 @@ private function getSuitesXML(string $suite_name = '')
34523466

34533467
foreach ($this->suites as $suite_name => $suite) {
34543468
$result .= sprintf(
3455-
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL,
3469+
'<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" skip_ext="%d" time="%s">' . PHP_EOL,
34563470
$suite['name'],
34573471
$suite['test_total'],
34583472
$suite['test_fail'],
34593473
$suite['test_error'],
34603474
$suite['test_skip'],
3475+
$suite['test_skip_ext'],
34613476
$suite['execution_time']
34623477
);
34633478

@@ -3517,6 +3532,9 @@ public function markTestAs(
35173532
} elseif ('SKIP' == $type) {
35183533
$this->record($suite, 'test_skip');
35193534
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
3535+
} elseif ('SKIP_EXP' == $type) {
3536+
$this->record($suite, 'test_skip_ext');
3537+
$this->rootSuite['files'][$file_name]['xml'] .= "<skipped_ext>$escaped_message</skipped_ext>\n";
35203538
} elseif ('WARN' == $type) {
35213539
$this->record($suite, 'test_warn');
35223540
$this->rootSuite['files'][$file_name]['xml'] .= "<warning>$escaped_message</warning>\n";
@@ -3660,6 +3678,7 @@ private function mergeSuites(array &$dest, array $source): void
36603678
$dest['test_fail'] += $source['test_fail'];
36613679
$dest['test_error'] += $source['test_error'];
36623680
$dest['test_skip'] += $source['test_skip'];
3681+
$dest['test_skip_ext'] += $source['test_skip_ext'];
36633682
$dest['test_warn'] += $source['test_warn'];
36643683
$dest['execution_time'] += $source['execution_time'];
36653684
$dest['files'] += $source['files'];

0 commit comments

Comments
 (0)