76
76
PTRN_IMPORT_ERROR = re .compile (r".*cannot import name \'(?P<module>.*)\'.*" , re .DOTALL )
77
77
PTRN_REMOTE_HOST = re .compile (r"(?P<user>\w+)@(?P<host>[\w.]+):(?P<path>.+)" )
78
78
PTRN_VALID_CSV_NAME = re .compile (r"unittests-\d{4}-\d{2}-\d{2}.csv" )
79
- PTRN_TEST_STATUS_INDIVIDUAL = re .compile (r"(?P<name>test_ [\w_]+ \(.+\)) ... (?P<status>.+)" )
80
- PTRN_TEST_STATUS_ERROR = re .compile (r"(?P<status>.+): (?P<name>test_ [\w_]+ \(.+\))" )
79
+ PTRN_TEST_STATUS_INDIVIDUAL = re .compile (r"(?P<name>test [\w_]+ \(.+? \)) ... (?P<status>.+)" )
80
+ PTRN_TEST_STATUS_ERROR = re .compile (r"(?P<status>.+): (?P<name>test [\w_]+ \(.+? \))" )
81
81
82
82
83
83
# ----------------------------------------------------------------------------------------------------------------------
@@ -240,11 +240,14 @@ def __init__(self):
240
240
# tracked stats
241
241
self ._tracked = False
242
242
243
- def all_ok (self ):
243
+ def _reset (self ):
244
244
self ._num_fails = 0
245
245
self ._num_errors = 0
246
246
self ._num_skipped = 0
247
247
248
+ def all_ok (self ):
249
+ self ._reset ()
250
+
248
251
@property
249
252
def num_errors (self ):
250
253
return self ._num_errors
@@ -270,7 +273,7 @@ def num_skipped(self):
270
273
@num_skipped .setter
271
274
def num_skipped (self , value ):
272
275
if not self ._tracked :
273
- self ._num_fails = value
276
+ self ._num_skipped = value
274
277
275
278
@property
276
279
def num_passes (self ):
@@ -279,25 +282,28 @@ def num_passes(self):
279
282
return - 1
280
283
281
284
def update (self , test_detailed_stats ):
282
- for test , stats in test_detailed_stats . items () :
285
+ if len ( test_detailed_stats ) > 0 :
283
286
self ._tracked = True
284
- stats = {s .lower () for s in stats }
285
- if TestStatus .ERROR in stats :
286
- self ._num_errors = 1 if self ._num_errors == - 1 else self ._num_errors + 1
287
- elif TestStatus .FAIL in stats :
288
- self ._num_fails = 1 if self ._num_fails == - 1 else self ._num_fails + 1
289
- else :
290
- for s in stats :
291
- if s .startswith (TestStatus .SKIPPED ):
292
- self ._num_skipped = 1 if self ._num_skipped == - 1 else self ._num_skipped + 1
293
- break
287
+ self ._reset ()
288
+ for test , stats in test_detailed_stats .items ():
289
+ stats = {s .lower () for s in stats }
290
+ if TestStatus .ERROR in stats :
291
+ self ._num_errors += 1
292
+ elif TestStatus .FAIL in stats :
293
+ self ._num_fails += 1
294
+ else :
295
+ for s in stats :
296
+ if s .startswith (TestStatus .SKIPPED ):
297
+ self ._num_skipped += 1
298
+ break
294
299
295
300
296
301
def process_output (output_lines ):
297
302
if isinstance (output_lines , str ):
298
303
output_lines = output_lines .split ("\n " )
299
304
300
305
unittests = []
306
+ # stats tracked per unittest
301
307
unittest_tests = defaultdict (list )
302
308
error_messages = defaultdict (set )
303
309
java_exceptions = defaultdict (set )
@@ -308,6 +314,7 @@ def process_output(output_lines):
308
314
if match :
309
315
unittest = match .group ('unittest' )
310
316
unittests .append (unittest )
317
+ unittest_tests .clear ()
311
318
continue
312
319
313
320
# extract python reported python error messages
@@ -323,15 +330,10 @@ def process_output(output_lines):
323
330
continue
324
331
325
332
# stats
326
- # tracking
333
+ # tracking stats
327
334
match = re .match (PTRN_TEST_STATUS_INDIVIDUAL , line )
328
- if match :
329
- name = match .group ('name' )
330
- status = match .group ('status' )
331
- unittest_tests [name ].append (status )
332
- continue
333
-
334
- match = re .match (PTRN_TEST_STATUS_ERROR , line )
335
+ if not match :
336
+ match = re .match (PTRN_TEST_STATUS_ERROR , line )
335
337
if match :
336
338
name = match .group ('name' )
337
339
status = match .group ('status' )
0 commit comments