62
62
CSV_RESULTS_NAME = "{}.csv" .format (_BASE_NAME )
63
63
HTML_RESULTS_NAME = "{}.html" .format (_BASE_NAME )
64
64
65
+ HR = "" .join (['-' for _ in range (120 )])
65
66
66
67
PTRN_ERROR = re .compile (r'^(?P<error>[A-Z][a-z][a-zA-Z]+):(?P<message>.*)$' )
67
- PTRN_UNITTEST = re .compile (r'^#### running: graalpython/lib-python/3/test/(?P<unittest>.*)$' )
68
+ PTRN_UNITTEST = re .compile (r'^#### running: graalpython/lib-python/3/test/(?P<unittest>[\w.]+).*$' , re . DOTALL )
68
69
PTRN_NUM_TESTS = re .compile (r'^Ran (?P<num_tests>\d+) test.*$' )
69
70
PTRN_FAILED = re .compile (
70
71
r'^FAILED \((failures=(?P<failures>\d+))?(, )?(errors=(?P<errors>\d+))?(, )?(skipped=(?P<skipped>\d+))?\)$' )
@@ -126,8 +127,11 @@ def scp(results_file_path, destination_path, destination_name=None):
126
127
return _run_cmd (cmd )[0 ]
127
128
128
129
129
- def _run_unittest (test_path ):
130
- cmd = ["mx" , "python3" , "--python.CatchAllExceptions=true" , test_path , "-v" ]
130
+ def _run_unittest (test_path , with_cpython = False ):
131
+ if with_cpython :
132
+ cmd = ["python3" , test_path , "-v" ]
133
+ else :
134
+ cmd = ["mx" , "python3" , "--python.CatchAllExceptions=true" , test_path , "-v" ]
131
135
success , output = _run_cmd (cmd )
132
136
output = '''
133
137
##############################################################
@@ -139,7 +143,7 @@ def _run_unittest(test_path):
139
143
TIMEOUT = 60 * 20 # 20 mins per unittest wait time max ...
140
144
141
145
142
- def run_unittests (unittests , timeout ):
146
+ def run_unittests (unittests , timeout , with_cpython = False ):
143
147
assert isinstance (unittests , (list , tuple ))
144
148
num_unittests = len (unittests )
145
149
log ("[EXEC] running {} unittests ... " , num_unittests )
@@ -148,7 +152,7 @@ def run_unittests(unittests, timeout):
148
152
149
153
pool = Pool ()
150
154
for ut in unittests :
151
- results .append (pool .apply_async (_run_unittest , args = (ut , )))
155
+ results .append (pool .apply_async (_run_unittest , args = (ut , with_cpython )))
152
156
pool .close ()
153
157
154
158
log ("[INFO] collect results ... " )
@@ -163,11 +167,12 @@ def run_unittests(unittests, timeout):
163
167
timed_out .append (unittests [i ])
164
168
log ("[PROGRESS] {} / {}: \t {}%" , i + 1 , num_unittests , int (((i + 1 ) * 100.0 ) / num_unittests ))
165
169
166
- log ("" .join (['-' for i in range (120 )]))
167
- for t in timed_out :
168
- log ("[TIMEOUT] skipped: {}" , t )
169
- log ("" .join (['-' for i in range (120 )]))
170
- log ("[STATS] processed {} out of {} unitttests" , num_unittests - len (timed_out ), num_unittests )
170
+ if timed_out :
171
+ log (HR )
172
+ for t in timed_out :
173
+ log ("[TIMEOUT] skipped: {}" , t )
174
+ log (HR )
175
+ log ("[STATS] processed {} out of {} unittests" , num_unittests - len (timed_out ), num_unittests )
171
176
pool .terminate ()
172
177
pool .join ()
173
178
return out
@@ -325,6 +330,11 @@ class Col(object):
325
330
NUM_SKIPPED = 'num_skipped'
326
331
NUM_PASSES = 'num_passes'
327
332
PYTHON_ERRORS = 'python_errors'
333
+ CPY_NUM_TESTS = 'cpy_num_tests'
334
+ CPY_NUM_FAILS = 'cpy_num_fails'
335
+ CPY_NUM_ERRORS = 'cpy_num_errors'
336
+ CPY_NUM_SKIPPED = 'cpy_num_skipped'
337
+ CPY_NUM_PASSES = 'cpy_num_passes'
328
338
329
339
330
340
CSV_HEADER = [
@@ -334,6 +344,11 @@ class Col(object):
334
344
Col .NUM_ERRORS ,
335
345
Col .NUM_SKIPPED ,
336
346
Col .NUM_PASSES ,
347
+ Col .CPY_NUM_TESTS ,
348
+ Col .CPY_NUM_FAILS ,
349
+ Col .CPY_NUM_ERRORS ,
350
+ Col .CPY_NUM_SKIPPED ,
351
+ Col .CPY_NUM_PASSES ,
337
352
Col .PYTHON_ERRORS
338
353
]
339
354
@@ -358,7 +373,7 @@ def save_as_txt(report_path, results):
358
373
return output
359
374
360
375
361
- def save_as_csv (report_path , unittests , error_messages , java_exceptions , stats ):
376
+ def save_as_csv (report_path , unittests , error_messages , java_exceptions , stats , cpy_stats = None ):
362
377
rows = []
363
378
with open (report_path , 'w' ) as CSV :
364
379
totals = {
@@ -373,18 +388,27 @@ def save_as_csv(report_path, unittests, error_messages, java_exceptions, stats):
373
388
374
389
for unittest in unittests :
375
390
unittest_stats = stats [unittest ]
391
+ cpy_unittest_stats = cpy_stats [unittest ] if cpy_stats else None
376
392
unittest_errmsg = error_messages [unittest ]
377
393
if not unittest_errmsg :
378
394
unittest_errmsg = java_exceptions [unittest ]
379
395
380
396
rows .append ({
381
397
Col .UNITTEST : unittest ,
398
+ # graalpython stats
382
399
Col .NUM_TESTS : unittest_stats .num_tests ,
383
400
Col .NUM_FAILS : unittest_stats .num_fails ,
384
401
Col .NUM_ERRORS : unittest_stats .num_errors ,
385
402
Col .NUM_SKIPPED : unittest_stats .num_skipped ,
386
403
Col .NUM_PASSES : unittest_stats .num_passes ,
387
- Col .PYTHON_ERRORS : dumps (list (unittest_errmsg ))
404
+ # cpython stats
405
+ Col .CPY_NUM_TESTS : cpy_unittest_stats .num_tests if cpy_unittest_stats else None ,
406
+ Col .CPY_NUM_FAILS : cpy_unittest_stats .num_fails if cpy_unittest_stats else None ,
407
+ Col .CPY_NUM_ERRORS : cpy_unittest_stats .num_errors if cpy_unittest_stats else None ,
408
+ Col .CPY_NUM_SKIPPED : cpy_unittest_stats .num_skipped if cpy_unittest_stats else None ,
409
+ Col .CPY_NUM_PASSES : cpy_unittest_stats .num_passes if cpy_unittest_stats else None ,
410
+ # errors
411
+ Col .PYTHON_ERRORS : dumps (list (unittest_errmsg )),
388
412
})
389
413
390
414
# update totals that ran in some way
@@ -695,14 +719,23 @@ def _fmt(t):
695
719
skip_tests = set ([_fmt (test ) for test in flags .skip_tests .split ("," )]) if flags .skip_tests else None
696
720
unittests = get_unittests (flags .tests_path , limit = flags .limit , skip_tests = skip_tests )
697
721
698
- results = run_unittests (unittests , flags .timeout )
722
+ # get cpython stats
723
+ log (HR )
724
+ log ("[INFO] get cpython stats" )
725
+ cpy_results = run_unittests (unittests , flags .timeout , with_cpython = True )
726
+ cpy_stats = process_output ('\n ' .join (cpy_results ))[- 1 ]
727
+
728
+ # get graalpython stats
729
+ log (HR )
730
+ log ("[INFO] get graalpython stats" )
731
+ results = run_unittests (unittests , flags .timeout , with_cpython = False )
699
732
txt_report_path = file_name (TXT_RESULTS_NAME , current_date )
700
733
output = save_as_txt (txt_report_path , results )
701
734
702
735
unittests , error_messages , java_exceptions , stats = process_output (output )
703
736
704
737
csv_report_path = file_name (CSV_RESULTS_NAME , current_date )
705
- rows , totals = save_as_csv (csv_report_path , unittests , error_messages , java_exceptions , stats )
738
+ rows , totals = save_as_csv (csv_report_path , unittests , error_messages , java_exceptions , stats , cpy_stats = cpy_stats )
706
739
707
740
missing_modules = process_errors (unittests , error_messages , 'ModuleNotFoundError' ,
708
741
msg_processor = get_missing_module )
0 commit comments