@@ -199,6 +199,7 @@ def __init__(self, cwd, assignment, verbosity=0):
199199 self .num_abort = 0
200200 self .num_error = 0
201201 self .verbosity = verbosity
202+ self .spamminess = 0
202203
203204 def run (self , check ):
204205 parameters = check .get ('parameters' )
@@ -221,9 +222,11 @@ def run(self, check):
221222 }
222223 if self .verbosity > 1 and invocation ["stdout" ]:
223224 print ("\n " .join (invocation ["stdout" ]))
225+ self .spamminess += 1
224226 # the following check used to be "> 0", but this is quite verbose...
225227 if invocation ['rc' ] or self .verbosity > 1 and invocation ["stderr" ]:
226228 print ("\n " .join (invocation ["stderr" ]))
229+ self .spamminess += 1
227230 self .memo [memo_key ] = invocation
228231 logger .debug (f".. rc { invocation ['rc' ]} , { invocation ['critical' ]} critical, { invocation ['error' ]} error" )
229232 self .num_abort += invocation ["critical" ]
@@ -260,18 +263,18 @@ def finalize(self, permissible_ids=None):
260263 return final
261264
262265
263- def run_suite (suite : TestSuite , runner : CheckRunner , results : ResultBuilder ):
264- """run all checks of `suite` using `runner`, collecting ` results`"""
266+ def run_suite (suite : TestSuite , runner : CheckRunner ):
267+ """run all checks of `suite` using `runner`, returning results dict via `ResultBuilder `"""
265268 suite .check_sanity ()
269+ builder = ResultBuilder (suite .name )
266270 for check in suite .checks :
267271 invocation = runner .run (check )
268272 for id_ , value in invocation ["results" ].items ():
269- results .record (id_ , result = value , invocation = invocation ['id' ])
273+ builder .record (id_ , result = value , invocation = invocation ['id' ])
274+ return builder .finalize (permissible_ids = suite .ids )
270275
271276
272- def print_report (subject : str , suite : TestSuite , targets : dict , results : dict , verbose = False ):
273- if verbose :
274- print ("********" * 10 )
277+ def print_report (subject : str , suite : TestSuite , targets : dict , results : dict ):
275278 print (f"{ subject } { suite .name } :" )
276279 for tname , target_spec in targets .items ():
277280 by_result = suite .select (tname , target_spec ).evaluate (results )
@@ -287,10 +290,13 @@ def print_report(subject: str, suite: TestSuite, targets: dict, results: dict, v
287290 for offenders , category in ((failed , 'FAILED' ), (missing , 'MISSING' )):
288291 if category == 'MISSING' and suite .partial :
289292 continue # do not report each missing testcase if a filter was used
293+ if not offenders :
294+ continue
295+ print (f" - { category } :" )
290296 for testcase in offenders :
291- print (f" - { category } { testcase ['id' ]} " )
297+ print (f" - { testcase ['id' ]} : " )
292298 if 'description' in testcase : # used to be `verbose and ...`, but users need the URL!
293- print (' ' + testcase ['description' ])
299+ print (f" > { testcase ['description' ]. strip () } " )
294300
295301
296302def create_report (argv , config , spec , versions , invocations ):
@@ -344,6 +350,8 @@ def main(argv):
344350 check_cwd = os .path .dirname (config .arg0 ) or os .getcwd ()
345351 runner = CheckRunner (check_cwd , config .assignment , verbosity = config .verbose and 2 or not config .quiet )
346352 version_report = {}
353+ # collect report data as tuples (version, suite, results) before printing them
354+ report_data = []
347355 for version in versions :
348356 vname = version ['version' ]
349357 suite = compile_suite (
@@ -352,12 +360,16 @@ def main(argv):
352360 config .sections ,
353361 config .tests ,
354362 )
355- builder = ResultBuilder (suite .name )
356- run_suite (suite , runner , builder )
357- results = version_report [vname ] = builder .finalize (permissible_ids = suite .ids )
358- if not config .quiet :
359- print_report (config .subject , suite , version ['targets' ], results , verbose = config .verbose )
363+ report_data .append ((version , suite , run_suite (suite , runner )))
364+ # now report: to console if requested, and likewise for yaml output
365+ if not config .quiet :
366+ # print a horizontal line if we had any script output
367+ if runner .spamminess :
368+ print ("********" * 10 ) # 80 characters
369+ for version , suite , results in report_data :
370+ print_report (config .subject , suite , version ['targets' ], results )
360371 if config .output :
372+ version_report = {version ['version' ]: results for version , _ , results in report_data }
361373 report = create_report (argv , config , spec , version_report , runner .get_invocations ())
362374 with open (config .output , 'w' , encoding = 'UTF-8' ) as fileobj :
363375 yaml .safe_dump (report , fileobj , default_flow_style = False , sort_keys = False )
0 commit comments