1414
1515
1616def print_failure_header (test , is_flaky = False ):
17- text = [str ( test ) ]
17+ text = [test . full_name ]
1818 if test .output_proc .negative :
1919 text .append ('[negative]' )
2020 if is_flaky :
@@ -24,6 +24,23 @@ 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+
2744class ProgressIndicator ():
2845
2946 def __init__ (self , context , options , test_count ):
@@ -68,19 +85,7 @@ def finished(self):
6885 for test , result , is_flaky in self ._failed :
6986 flaky += int (is_flaky )
7087 print_failure_header (test , is_flaky = is_flaky )
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 ---" )
88+ print (formatted_result_output (result ))
8489 if len (self ._failed ) == 0 :
8590 print ("===" )
8691 print ("=== All tests succeeded" )
@@ -230,7 +235,7 @@ def on_test_result(self, test, result):
230235 else :
231236 self ._passed += 1
232237
233- self ._print_progress (str ( test ) )
238+ self ._print_progress (test . full_name )
234239 if result .has_unexpected_output :
235240 output = result .output
236241 stdout = output .stdout .strip ()
@@ -358,10 +363,7 @@ def __init__(self, context, options, test_count, framework_name):
358363 self .test_count = 0
359364
360365 def on_test_result (self , test , result ):
361- if result .is_rerun :
362- self .process_results (test , result .results )
363- else :
364- self .process_results (test , [result ])
366+ self .process_results (test , result .as_list )
365367
366368 def process_results (self , test , results ):
367369 for run , result in enumerate (results ):
@@ -376,7 +378,7 @@ def process_results(self, test, results):
376378 if not result .has_unexpected_output and run == 0 :
377379 continue
378380
379- record = self ._test_record (test , result , output , run )
381+ record = self ._test_record (test , result , run )
380382 record .update ({
381383 "result" : test .output_proc .get_outcome (output ),
382384 "stdout" : output .stdout ,
@@ -392,41 +394,33 @@ def result_value(test, result, output):
392394 return ""
393395 return test .output_proc .get_outcome (output )
394396
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- } )
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+ )
400402 self .tests .add (record )
401403 self .duration_sum += record ['duration' ]
402404 self .test_count += 1
403405
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- }
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
419413
420414 def finished (self ):
421415 duration_mean = None
422416 if self .test_count :
423417 duration_mean = self .duration_sum / self .test_count
424418
425419 result = {
426- " results" : self .results ,
427- " slowest_tests" : self .tests .as_list (),
428- " duration_mean" : duration_mean ,
429- " test_total" : self .test_count ,
420+ ' results' : self .results ,
421+ ' slowest_tests' : self .tests .as_list (),
422+ ' duration_mean' : duration_mean ,
423+ ' test_total' : self .test_count ,
430424 }
431425
432426 with open (self .options .json_test_results , "w" ) as f :
0 commit comments