@@ -116,6 +116,25 @@ def __init__(self, cases, flaky_tests_mode):
116116 self .lock = threading .Lock ()
117117 self .shutdown_event = threading .Event ()
118118
119+ def GetFailureOutput (self , failure ):
120+ output = []
121+ if failure .output .stderr :
122+ output += ["--- stderr ---" ]
123+ output += [failure .output .stderr .strip ()]
124+ if failure .output .stdout :
125+ output += ["--- stdout ---" ]
126+ output += [failure .output .stdout .strip ()]
127+ output += ["Command: %s" % EscapeCommand (failure .command )]
128+ if failure .HasCrashed ():
129+ output += ["--- %s ---" % PrintCrashed (failure .output .exit_code )]
130+ if failure .HasTimedOut ():
131+ output += ["--- TIMEOUT ---" ]
132+ output = "\n " .join (output )
133+ return output
134+
135+ def PrintFailureOutput (self , failure ):
136+ print (self .GetFailureOutput (failure ))
137+
119138 def PrintFailureHeader (self , test ):
120139 if test .IsNegative ():
121140 negative_marker = '[negative] '
@@ -224,17 +243,7 @@ def Done(self):
224243 print ()
225244 for failed in self .failed :
226245 self .PrintFailureHeader (failed .test )
227- if failed .output .stderr :
228- print ("--- stderr ---" )
229- print (failed .output .stderr .strip ())
230- if failed .output .stdout :
231- print ("--- stdout ---" )
232- print (failed .output .stdout .strip ())
233- print ("Command: %s" % EscapeCommand (failed .command ))
234- if failed .HasCrashed ():
235- print ("--- %s ---" % PrintCrashed (failed .output .exit_code ))
236- if failed .HasTimedOut ():
237- print ("--- TIMEOUT ---" )
246+ self .PrintFailureOutput (failed )
238247 if len (self .failed ) == 0 :
239248 print ("===" )
240249 print ("=== All tests succeeded" )
@@ -288,6 +297,21 @@ def HasRun(self, output):
288297 sys .stdout .write ('.' )
289298 sys .stdout .flush ()
290299
300+ class ActionsAnnotationProgressIndicator (DotsProgressIndicator ):
301+ def GetAnnotationInfo (self , test , output ):
302+ traceback = output .stdout + output .stderr
303+ find_full_path = re .search (r' +at .*\(.*%s:([0-9]+):([0-9]+)' % test .file , traceback )
304+ col = line = 0
305+ if find_full_path :
306+ line , col = map (int , find_full_path .groups ())
307+ root_path = abspath (join (dirname (__file__ ), '../' )) + os .sep
308+ filename = test .file .replace (root_path , "" )
309+ return filename , line , col
310+
311+ def PrintFailureOutput (self , failure ):
312+ output = self .GetFailureOutput (failure )
313+ filename , line , column = self .GetAnnotationInfo (failure .test , failure .output )
314+ print ("::error file=%s,line=%d,col=%d::%s" % (filename , line , column , output .replace ('\n ' , '%0A' )))
291315
292316class TapProgressIndicator (SimpleProgressIndicator ):
293317
@@ -496,6 +520,7 @@ def ClearLine(self, last_line_length):
496520PROGRESS_INDICATORS = {
497521 'verbose' : VerboseProgressIndicator ,
498522 'dots' : DotsProgressIndicator ,
523+ 'actions' : ActionsAnnotationProgressIndicator ,
499524 'color' : ColorProgressIndicator ,
500525 'tap' : TapProgressIndicator ,
501526 'mono' : MonochromeProgressIndicator ,
@@ -1299,7 +1324,7 @@ def BuildOptions():
12991324 result .add_option ('--logfile' , dest = 'logfile' ,
13001325 help = 'write test output to file. NOTE: this only applies the tap progress indicator' )
13011326 result .add_option ("-p" , "--progress" ,
1302- help = "The style of progress indicator (verbose, dots, color, mono, tap)" ,
1327+ help = "The style of progress indicator (%s)" % ", " . join ( PROGRESS_INDICATORS . keys ()) ,
13031328 choices = list (PROGRESS_INDICATORS .keys ()), default = "mono" )
13041329 result .add_option ("--report" , help = "Print a summary of the tests to be run" ,
13051330 default = False , action = "store_true" )
0 commit comments