@@ -427,11 +427,31 @@ def _patch_report(report):
427427 log .append ('arguments: ' + shlex .join (run ['argv' ]))
428428 for invdata in run ['invocations' ].values ():
429429 log .append ('$ ' + invdata ['cmd' ])
430- log .extend (invdata ['stderr' ])
430+ for line in invdata ['stderr' ]:
431+ if line .startswith ('DEBUG: ** ' ):
432+ testcase_id = line .split ()[2 ]
433+ line = f'INFO: *** { testcase_id } '
434+ log .append (line )
431435 for tc_id , value in invdata ['results' ].items ():
432436 tests [tc_id ] = {'result' : value }
433437
434438
439+ def _augment_report (report ):
440+ tests = report .get ('tests' , {})
441+ log = []
442+ for line in report .get ('log' , ()):
443+ if line .startswith ('INFO: *** ' ):
444+ testcase_id = line .split ()[2 ]
445+ result = tests .get (testcase_id )
446+ if result is not None :
447+ result ['_inlog' ] = True
448+ val = result .get ('result' , None )
449+ verdict = {1 : 'PASS' , 0 : 'DNF' , - 1 : 'FAIL' }.get (val , 'N/A' )
450+ line = f'INFO: *** { testcase_id } ({ verdict } )'
451+ log .append (line )
452+ report ['log' ] = log
453+
454+
435455@app .post ("/reports" )
436456async def post_report (
437457 request : Request ,
@@ -590,7 +610,20 @@ def report_url(report, *args, **kwargs): return _build_report_url(base_url, repo
590610def _redact_report (report ):
591611 """remove all lines from script output in `report` that are not directly linked to any testcase"""
592612 log = report ['log' ]
593- redacted = [line for line in log if line .split (':' , 1 )[0 ] in ('WARNING' , 'ERROR' , 'CRITICAL' )]
613+ # don't do list comprehension here because it would restrict the logic
614+ # (e.g. hard to replace a batch of lines by a different batch of lines)
615+ redacted = []
616+ for line in log :
617+ parts = line .split (': ' , 1 )
618+ if len (parts ) != 2 :
619+ continue
620+ # don't redact 'official' error messages
621+ # this can still leak information and should be changed
622+ if parts [0 ] in ('WARNING' , 'ERROR' , 'CRITICAL' ):
623+ redacted .append (line )
624+ # don't redact the line that states what testcase is now being tested
625+ elif parts [0 ] in ('INFO' , ) and parts [1 ].startswith ('***' ):
626+ redacted .append (line )
594627 report ['log' ] = redacted
595628 return len (log ) != len (redacted )
596629
@@ -618,6 +651,7 @@ async def get_report_view(
618651 raise HTTPException (status_code = 404 )
619652 report = reports [0 ]
620653 _patch_report (report )
654+ _augment_report (report )
621655 redacted = _redact_report (report )
622656 return render_view (
623657 VIEW_REPORT , view_type , report = report , base_url = settings .base_url ,
@@ -640,6 +674,7 @@ async def get_report_view_full(
640674 raise HTTPException (status_code = 404 )
641675 report = reports [0 ]
642676 _patch_report (report )
677+ _augment_report (report )
643678 check_role (account , report ['subject' ], ROLES ['read_any' ])
644679 return render_view (
645680 VIEW_REPORT , view_type , report = report , base_url = settings .base_url ,
0 commit comments