Skip to content

Commit 2e90bbe

Browse files
committed
Return to old counting where every test is counted (even those of skipped
extensions). Inform about the number of extensions tested and skipped. This makes the test summary more compareable. Maybe i'll add a parameter/env-var to skip extension tests. That way we could fasten tests for changes in the core. But it has to wait some days.
1 parent 9f2b70d commit 2e90bbe

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

run-tests.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,28 +137,29 @@
137137
// Compile a list of all test files (*.phpt).
138138
$test_files = array();
139139
$exts_to_test = get_loaded_extensions();
140+
$exts_tested = count($exts_to_test);
141+
$exts_skipped = 0;
142+
$ignored_by_ext = 0;
140143
sort($exts_to_test);
141-
$extra_dirs = array('pear', 'tests');
144+
$test_dirs = array('tests', 'pear', 'ext');
142145
$cwd=getcwd();
143146

144-
// First get list of test files in ext/
145-
foreach ($exts_to_test as $dir) {
146-
find_files("{$cwd}/ext/{$dir}");
147+
foreach ($test_dirs as $dir) {
148+
find_files("{$cwd}/{$dir}", $dir=='ext');
147149
}
148150

149-
// Then the rest
150-
foreach ($extra_dirs as $dir) {
151-
find_files("{$cwd}/{$dir}");
152-
}
153-
154-
function find_files($dir)
151+
function find_files($dir,$is_ext_dir=false,$ignore=false)
155152
{
156-
global $test_files;
153+
global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested;
157154

158155
$o = opendir($dir) or error("cannot open directory: $dir");
159156
while (($name = readdir($o)) !== false) {
160157
if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS'))) {
161-
find_files("{$dir}/{$name}");
158+
$skip_ext = ($is_ext_dir && !in_array($name, $exts_to_test));
159+
if ($skip_ext) {
160+
$exts_skipped++;
161+
}
162+
find_files("{$dir}/{$name}", false, $ignore || $skip_ext);
162163
}
163164

164165
// Cleanup any left-over tmp files from last run.
@@ -169,8 +170,12 @@ function find_files($dir)
169170

170171
// Otherwise we're only interested in *.phpt files.
171172
if (substr($name, -5) == '.phpt') {
172-
$testfile = realpath("{$dir}/{$name}");
173-
$test_files[] = $testfile;
173+
if ($ignore) {
174+
$ignored_by_ext++;
175+
} else {
176+
$testfile = realpath("{$dir}/{$name}");
177+
$test_files[] = $testfile;
178+
}
174179
}
175180
}
176181
closedir($o);
@@ -206,10 +211,13 @@ function find_files($dir)
206211
}
207212

208213
$n_total = count($test_results);
214+
$n_total += $ignored_by_ext;
215+
209216
$sum_results = array('PASSED'=>0, 'SKIPPED'=>0, 'FAILED'=>0);
210217
foreach ($test_results as $v) {
211218
$sum_results[$v]++;
212219
}
220+
$sum_results['SKIPPED'] += $ignored_by_ext;
213221
$percent_results = array();
214222
while (list($v,$n) = each($sum_results)) {
215223
$percent_results[$v] = (100.0 * $n) / $n_total;
@@ -221,10 +229,14 @@ function find_files($dir)
221229
=====================================================================
222230
TEST RESULT SUMMARY
223231
---------------------------------------------------------------------
232+
Exts skipped : " . sprintf("%4d",$exts_skipped) . "
233+
Exts tested : " . sprintf("%4d",$exts_tested) . "
234+
---------------------------------------------------------------------
224235
Number of tests : " . sprintf("%4d",$n_total) . "
225236
Tests skipped : " . sprintf("%4d (%2.1f%%)",$sum_results['SKIPPED'],$percent_results['SKIPPED']) . "
226237
Tests failed : " . sprintf("%4d (%2.1f%%)",$sum_results['FAILED'],$percent_results['FAILED']) . "
227238
Tests passed : " . sprintf("%4d (%2.1f%%)",$sum_results['PASSED'],$percent_results['PASSED']) . "
239+
---------------------------------------------------------------------
228240
Time taken : " . sprintf("%4d seconds", $end_time - $start_time) . "
229241
=====================================================================
230242
";

0 commit comments

Comments
 (0)