6
6
See lit.pod for more information.
7
7
"""
8
8
9
- from __future__ import absolute_import
10
9
import os
11
10
import platform
12
11
import sys
@@ -59,14 +58,6 @@ def main_with_tmp(builtinParameters):
59
58
return
60
59
61
60
userParams = create_user_parameters (builtinParameters , opts )
62
-
63
- # Decide what the requested maximum indvidual test time should be
64
- if opts .maxIndividualTestTime is not None :
65
- maxIndividualTestTime = opts .maxIndividualTestTime
66
- else :
67
- # Default is zero
68
- maxIndividualTestTime = 0
69
-
70
61
isWindows = platform .system () == 'Windows'
71
62
72
63
# Create the global config object.
@@ -82,18 +73,14 @@ def main_with_tmp(builtinParameters):
82
73
isWindows = isWindows ,
83
74
params = userParams ,
84
75
config_prefix = opts .configPrefix ,
85
- maxIndividualTestTime = maxIndividualTestTime ,
86
76
maxFailures = opts .maxFailures ,
87
- parallelism_groups = {},
88
77
echo_all_commands = opts .echoAllCommands )
89
78
90
79
# Perform test discovery.
91
80
tests = lit .discovery .find_tests_for_inputs (litConfig , opts .test_paths )
92
81
93
- # After test discovery the configuration might have changed
94
- # the maxIndividualTestTime. If we explicitly set this on the
95
- # command line then override what was set in the test configuration
96
- if opts .maxIndividualTestTime is not None :
82
+ # Command line overrides configuration for maxIndividualTestTime.
83
+ if opts .maxIndividualTestTime is not None : # `not None` is important (default: 0)
97
84
if opts .maxIndividualTestTime != litConfig .maxIndividualTestTime :
98
85
litConfig .note (('The test suite configuration requested an individual'
99
86
' test timeout of {0} seconds but a timeout of {1} seconds was'
@@ -148,55 +135,7 @@ def main_with_tmp(builtinParameters):
148
135
if opts .output_path is not None :
149
136
write_test_results (tests , litConfig , testing_time , opts .output_path )
150
137
151
- # List test results organized by kind.
152
- hasFailures = False
153
- byCode = {}
154
- for test in tests :
155
- if test .result .code not in byCode :
156
- byCode [test .result .code ] = []
157
- byCode [test .result .code ].append (test )
158
- if test .result .code .isFailure :
159
- hasFailures = True
160
-
161
- # Print each test in any of the failing groups.
162
- for title ,code in (('Unexpected Passing Tests' , lit .Test .XPASS ),
163
- ('Failing Tests' , lit .Test .FAIL ),
164
- ('Unresolved Tests' , lit .Test .UNRESOLVED ),
165
- ('Unsupported Tests' , lit .Test .UNSUPPORTED ),
166
- ('Expected Failing Tests' , lit .Test .XFAIL ),
167
- ('Timed Out Tests' , lit .Test .TIMEOUT )):
168
- if (lit .Test .XFAIL == code and not opts .show_xfail ) or \
169
- (lit .Test .UNSUPPORTED == code and not opts .show_unsupported ) or \
170
- (lit .Test .UNRESOLVED == code and (opts .maxFailures is not None )):
171
- continue
172
- elts = byCode .get (code )
173
- if not elts :
174
- continue
175
- print ('*' * 20 )
176
- print ('%s (%d):' % (title , len (elts )))
177
- for test in elts :
178
- print (' %s' % test .getFullName ())
179
- sys .stdout .write ('\n ' )
180
-
181
- if opts .timeTests and tests :
182
- # Order by time.
183
- test_times = [(test .getFullName (), test .result .elapsed )
184
- for test in tests ]
185
- lit .util .printHistogram (test_times , title = 'Tests' )
186
-
187
- for name ,code in (('Expected Passes ' , lit .Test .PASS ),
188
- ('Passes With Retry ' , lit .Test .FLAKYPASS ),
189
- ('Expected Failures ' , lit .Test .XFAIL ),
190
- ('Unsupported Tests ' , lit .Test .UNSUPPORTED ),
191
- ('Unresolved Tests ' , lit .Test .UNRESOLVED ),
192
- ('Unexpected Passes ' , lit .Test .XPASS ),
193
- ('Unexpected Failures' , lit .Test .FAIL ),
194
- ('Individual Timeouts' , lit .Test .TIMEOUT )):
195
- if opts .quiet and not code .isFailure :
196
- continue
197
- N = len (byCode .get (code ,[]))
198
- if N :
199
- print (' %s: %d' % (name ,N ))
138
+ hasFailures = print_summary (tests , opts )
200
139
201
140
if opts .xunit_output_file :
202
141
write_test_results_xunit (tests , opts )
@@ -320,12 +259,58 @@ def progress_callback(test):
320
259
display .finish ()
321
260
return testing_time
322
261
323
- def write_test_results (tests , lit_config , testing_time , output_path ):
324
- try :
325
- import json
326
- except ImportError :
327
- lit_config .fatal ('test output unsupported with Python 2.5' )
262
+ def print_summary (tests , opts ):
263
+ hasFailures = False
264
+ byCode = {}
265
+ for test in tests :
266
+ if test .result .code not in byCode :
267
+ byCode [test .result .code ] = []
268
+ byCode [test .result .code ].append (test )
269
+ if test .result .code .isFailure :
270
+ hasFailures = True
271
+
272
+ # Print each test in any of the failing groups.
273
+ for title ,code in (('Unexpected Passing Tests' , lit .Test .XPASS ),
274
+ ('Failing Tests' , lit .Test .FAIL ),
275
+ ('Unresolved Tests' , lit .Test .UNRESOLVED ),
276
+ ('Unsupported Tests' , lit .Test .UNSUPPORTED ),
277
+ ('Expected Failing Tests' , lit .Test .XFAIL ),
278
+ ('Timed Out Tests' , lit .Test .TIMEOUT )):
279
+ if (lit .Test .XFAIL == code and not opts .show_xfail ) or \
280
+ (lit .Test .UNSUPPORTED == code and not opts .show_unsupported ) or \
281
+ (lit .Test .UNRESOLVED == code and (opts .maxFailures is not None )):
282
+ continue
283
+ elts = byCode .get (code )
284
+ if not elts :
285
+ continue
286
+ print ('*' * 20 )
287
+ print ('%s (%d):' % (title , len (elts )))
288
+ for test in elts :
289
+ print (' %s' % test .getFullName ())
290
+ sys .stdout .write ('\n ' )
291
+
292
+ if opts .timeTests and tests :
293
+ # Order by time.
294
+ test_times = [(test .getFullName (), test .result .elapsed )
295
+ for test in tests ]
296
+ lit .util .printHistogram (test_times , title = 'Tests' )
297
+
298
+ for name ,code in (('Expected Passes ' , lit .Test .PASS ),
299
+ ('Passes With Retry ' , lit .Test .FLAKYPASS ),
300
+ ('Expected Failures ' , lit .Test .XFAIL ),
301
+ ('Unsupported Tests ' , lit .Test .UNSUPPORTED ),
302
+ ('Unresolved Tests ' , lit .Test .UNRESOLVED ),
303
+ ('Unexpected Passes ' , lit .Test .XPASS ),
304
+ ('Unexpected Failures' , lit .Test .FAIL ),
305
+ ('Individual Timeouts' , lit .Test .TIMEOUT )):
306
+ if opts .quiet and not code .isFailure :
307
+ continue
308
+ N = len (byCode .get (code ,[]))
309
+ if N :
310
+ print (' %s: %d' % (name ,N ))
311
+ return hasFailures
328
312
313
+ def write_test_results (tests , lit_config , testing_time , output_path ):
329
314
# Construct the data we will write.
330
315
data = {}
331
316
# Encode the current lit version as a schema version.
@@ -373,6 +358,7 @@ def write_test_results(tests, lit_config, testing_time, output_path):
373
358
# Write the output.
374
359
f = open (output_path , 'w' )
375
360
try :
361
+ import json
376
362
json .dump (data , f , indent = 2 , sort_keys = True )
377
363
f .write ('\n ' )
378
364
finally :
0 commit comments