137
137
// Compile a list of all test files (*.phpt).
138
138
$ test_files = array ();
139
139
$ exts_to_test = get_loaded_extensions ();
140
+ $ exts_tested = count ($ exts_to_test );
141
+ $ exts_skipped = 0 ;
142
+ $ ignored_by_ext = 0 ;
140
143
sort ($ exts_to_test );
141
- $ extra_dirs = array ('pear ' , 'tests ' );
144
+ $ test_dirs = array ('tests ' , ' pear ' , 'ext ' );
142
145
$ cwd =getcwd ();
143
146
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 ' );
147
149
}
148
150
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 )
155
152
{
156
- global $ test_files ;
153
+ global $ test_files, $ exts_to_test , $ ignored_by_ext , $ exts_skipped , $ exts_tested ;
157
154
158
155
$ o = opendir ($ dir ) or error ("cannot open directory: $ dir " );
159
156
while (($ name = readdir ($ o )) !== false ) {
160
157
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 );
162
163
}
163
164
164
165
// Cleanup any left-over tmp files from last run.
@@ -169,8 +170,12 @@ function find_files($dir)
169
170
170
171
// Otherwise we're only interested in *.phpt files.
171
172
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
+ }
174
179
}
175
180
}
176
181
closedir ($ o );
@@ -206,10 +211,13 @@ function find_files($dir)
206
211
}
207
212
208
213
$ n_total = count ($ test_results );
214
+ $ n_total += $ ignored_by_ext ;
215
+
209
216
$ sum_results = array ('PASSED ' =>0 , 'SKIPPED ' =>0 , 'FAILED ' =>0 );
210
217
foreach ($ test_results as $ v ) {
211
218
$ sum_results [$ v ]++;
212
219
}
220
+ $ sum_results ['SKIPPED ' ] += $ ignored_by_ext ;
213
221
$ percent_results = array ();
214
222
while (list ($ v ,$ n ) = each ($ sum_results )) {
215
223
$ percent_results [$ v ] = (100.0 * $ n ) / $ n_total ;
@@ -221,10 +229,14 @@ function find_files($dir)
221
229
=====================================================================
222
230
TEST RESULT SUMMARY
223
231
---------------------------------------------------------------------
232
+ Exts skipped : " . sprintf ("%4d " ,$ exts_skipped ) . "
233
+ Exts tested : " . sprintf ("%4d " ,$ exts_tested ) . "
234
+ ---------------------------------------------------------------------
224
235
Number of tests : " . sprintf ("%4d " ,$ n_total ) . "
225
236
Tests skipped : " . sprintf ("%4d (%2.1f%%) " ,$ sum_results ['SKIPPED ' ],$ percent_results ['SKIPPED ' ]) . "
226
237
Tests failed : " . sprintf ("%4d (%2.1f%%) " ,$ sum_results ['FAILED ' ],$ percent_results ['FAILED ' ]) . "
227
238
Tests passed : " . sprintf ("%4d (%2.1f%%) " ,$ sum_results ['PASSED ' ],$ percent_results ['PASSED ' ]) . "
239
+ ---------------------------------------------------------------------
228
240
Time taken : " . sprintf ("%4d seconds " , $ end_time - $ start_time ) . "
229
241
=====================================================================
230
242
" ;
0 commit comments