@@ -116,6 +116,25 @@ def __init__(self, cases, flaky_tests_mode):
116
116
self .lock = threading .Lock ()
117
117
self .shutdown_event = threading .Event ()
118
118
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
+
119
138
def PrintFailureHeader (self , test ):
120
139
if test .IsNegative ():
121
140
negative_marker = '[negative] '
@@ -224,17 +243,7 @@ def Done(self):
224
243
print ()
225
244
for failed in self .failed :
226
245
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 )
238
247
if len (self .failed ) == 0 :
239
248
print ("===" )
240
249
print ("=== All tests succeeded" )
@@ -288,6 +297,21 @@ def HasRun(self, output):
288
297
sys .stdout .write ('.' )
289
298
sys .stdout .flush ()
290
299
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' )))
291
315
292
316
class TapProgressIndicator (SimpleProgressIndicator ):
293
317
@@ -496,6 +520,7 @@ def ClearLine(self, last_line_length):
496
520
PROGRESS_INDICATORS = {
497
521
'verbose' : VerboseProgressIndicator ,
498
522
'dots' : DotsProgressIndicator ,
523
+ 'actions' : ActionsAnnotationProgressIndicator ,
499
524
'color' : ColorProgressIndicator ,
500
525
'tap' : TapProgressIndicator ,
501
526
'mono' : MonochromeProgressIndicator ,
@@ -1299,7 +1324,7 @@ def BuildOptions():
1299
1324
result .add_option ('--logfile' , dest = 'logfile' ,
1300
1325
help = 'write test output to file. NOTE: this only applies the tap progress indicator' )
1301
1326
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 ()) ,
1303
1328
choices = list (PROGRESS_INDICATORS .keys ()), default = "mono" )
1304
1329
result .add_option ("--report" , help = "Print a summary of the tests to be run" ,
1305
1330
default = False , action = "store_true" )
0 commit comments