1414
1515
1616def print_failure_header (test , is_flaky = False ):
17- text = [test . full_name ]
17+ text = [str ( test ) ]
1818 if test .output_proc .negative :
1919 text .append ('[negative]' )
2020 if is_flaky :
@@ -24,23 +24,6 @@ def print_failure_header(test, is_flaky=False):
2424 print (output .encode (encoding , errors = 'replace' ).decode (encoding ))
2525
2626
27- def formatted_result_output (result ):
28- lines = []
29- if result .output .stderr :
30- lines .append ("--- stderr ---" )
31- lines .append (result .output .stderr .strip ())
32- if result .output .stdout :
33- lines .append ("--- stdout ---" )
34- lines .append (result .output .stdout .strip ())
35- lines .append ("Command: %s" % result .cmd .to_string ())
36- if result .output .HasCrashed ():
37- lines .append ("exit code: %s" % result .output .exit_code_string )
38- lines .append ("--- CRASHED ---" )
39- if result .output .HasTimedOut ():
40- lines .append ("--- TIMEOUT ---" )
41- return '\n ' .join (lines )
42-
43-
4427class ProgressIndicator ():
4528
4629 def __init__ (self , context , options , test_count ):
@@ -85,7 +68,19 @@ def finished(self):
8568 for test , result , is_flaky in self ._failed :
8669 flaky += int (is_flaky )
8770 print_failure_header (test , is_flaky = is_flaky )
88- print (formatted_result_output (result ))
71+ if result .output .stderr :
72+ print ("--- stderr ---" )
73+ print (result .output .stderr .strip ())
74+ if result .output .stdout :
75+ print ("--- stdout ---" )
76+ print (result .output .stdout .strip ())
77+ print ("Command: %s" % result .cmd .to_string ())
78+ if result .output .HasCrashed ():
79+ print ("exit code: %s" % result .output .exit_code_string )
80+ print ("--- CRASHED ---" )
81+ crashed += 1
82+ if result .output .HasTimedOut ():
83+ print ("--- TIMEOUT ---" )
8984 if len (self ._failed ) == 0 :
9085 print ("===" )
9186 print ("=== All tests succeeded" )
@@ -235,7 +230,7 @@ def on_test_result(self, test, result):
235230 else :
236231 self ._passed += 1
237232
238- self ._print_progress (test . full_name )
233+ self ._print_progress (str ( test ) )
239234 if result .has_unexpected_output :
240235 output = result .output
241236 stdout = output .stdout .strip ()
@@ -363,7 +358,10 @@ def __init__(self, context, options, test_count, framework_name):
363358 self .test_count = 0
364359
365360 def on_test_result (self , test , result ):
366- self .process_results (test , result .as_list )
361+ if result .is_rerun :
362+ self .process_results (test , result .results )
363+ else :
364+ self .process_results (test , [result ])
367365
368366 def process_results (self , test , results ):
369367 for run , result in enumerate (results ):
@@ -378,7 +376,7 @@ def process_results(self, test, results):
378376 if not result .has_unexpected_output and run == 0 :
379377 continue
380378
381- record = self ._test_record (test , result , run )
379+ record = self ._test_record (test , result , output , run )
382380 record .update ({
383381 "result" : test .output_proc .get_outcome (output ),
384382 "stdout" : output .stdout ,
@@ -394,33 +392,41 @@ def result_value(test, result, output):
394392 return ""
395393 return test .output_proc .get_outcome (output )
396394
397- record = self ._test_record (test , result , run )
398- record .update (
399- result = result_value (test , result , output ),
400- marked_slow = test .is_slow ,
401- )
395+ record = self ._test_record (test , result , output , run )
396+ record .update ({
397+ " result" : result_value (test , result , output ),
398+ " marked_slow" : test .is_slow ,
399+ } )
402400 self .tests .add (record )
403401 self .duration_sum += record ['duration' ]
404402 self .test_count += 1
405403
406- def _test_record (self , test , result , run ):
407- record = util .base_test_record (test , result , run )
408- record .update (
409- framework_name = self .framework_name ,
410- command = result .cmd .to_string (relative = True ),
411- )
412- return record
404+ def _test_record (self , test , result , output , run ):
405+ return {
406+ "name" : str (test ),
407+ "flags" : result .cmd .args ,
408+ "command" : result .cmd .to_string (relative = True ),
409+ "run" : run + 1 ,
410+ "exit_code" : output .exit_code ,
411+ "expected" : test .expected_outcomes ,
412+ "duration" : output .duration ,
413+ "random_seed" : test .random_seed ,
414+ "target_name" : test .get_shell (),
415+ "variant" : test .variant ,
416+ "variant_flags" : test .variant_flags ,
417+ "framework_name" : self .framework_name ,
418+ }
413419
414420 def finished (self ):
415421 duration_mean = None
416422 if self .test_count :
417423 duration_mean = self .duration_sum / self .test_count
418424
419425 result = {
420- ' results' : self .results ,
421- ' slowest_tests' : self .tests .as_list (),
422- ' duration_mean' : duration_mean ,
423- ' test_total' : self .test_count ,
426+ " results" : self .results ,
427+ " slowest_tests" : self .tests .as_list (),
428+ " duration_mean" : duration_mean ,
429+ " test_total" : self .test_count ,
424430 }
425431
426432 with open (self .options .json_test_results , "w" ) as f :
0 commit comments