@@ -255,40 +255,51 @@ export class PackageTestRun {
255
255
const item = test && ( await this . #request. manager . resolveTestItem ( test , true ) ) ;
256
256
257
257
const elapsed = typeof msg . Elapsed === 'number' ? msg . Elapsed * 1000 : undefined ;
258
- switch ( msg . Action ) {
259
- case 'output' : {
260
- if ( ! msg . Output ) {
261
- break ;
262
- }
263
-
264
- // Track output
265
- const { id } = item || this . testItem ;
266
- if ( ! this . output . has ( id ) ) {
267
- this . output . set ( id , [ ] ) ;
268
- }
269
- this . output . get ( id ) ! . push ( msg . Output ) ;
270
-
271
- if ( ! item || / ^ ( = = = R U N | \s * - - - ( F A I L | P A S S ) : ) / . test ( msg . Output ) ) {
272
- this . append ( msg . Output , undefined , this . testItem ) ;
273
- break ;
274
- }
258
+ if ( msg . Action === 'output' ) {
259
+ if ( ! msg . Output ) {
260
+ return ;
261
+ }
275
262
276
- const { message, location } = parseOutputLocation ( msg . Output , path . join ( item . uri ! . fsPath , '..' ) ) ;
263
+ // Track output
264
+ const { id } = item || this . testItem ;
265
+ if ( ! this . output . has ( id ) ) {
266
+ this . output . set ( id , [ ] ) ;
267
+ }
268
+ this . output . get ( id ) ! . push ( msg . Output ) ;
269
+
270
+ let location : Location | undefined ;
271
+ let message = msg . Output ;
272
+ if ( item && ! / ^ ( = = = R U N | \s * - - - ( F A I L | P A S S ) : ) / . test ( msg . Output ) ) {
273
+ const parsed = parseOutputLocation ( msg . Output , path . join ( item . uri ! . fsPath , '..' ) ) ;
274
+ message = parsed . message ;
275
+ location = parsed . location ;
277
276
if ( location ) {
278
277
this . currentLocation . set ( id , location ) ;
278
+ } else {
279
+ location = this . currentLocation . get ( id ) ;
279
280
}
280
- this . append ( message , location || this . currentLocation . get ( id ) , item ) ;
281
-
282
- // Detect benchmark completion, e.g.
283
- // "BenchmarkFooBar-4 123456 123.4 ns/op 123 B/op 12 allocs/op"
284
- const m = msg . Output . match ( / ^ (?< name > B e n c h m a r k [ # / \w + ] + ) (?: - (?< procs > \d + ) \s + (?< result > .* ) ) ? (?: $ | \n ) / ) ;
285
- if ( m && msg . Test && m . groups ?. name === msg . Test ) {
286
- this . #run. passed ( item ) ;
287
- }
281
+ }
282
+ this . append ( message , location , item || this . testItem ) ;
288
283
289
- break ;
284
+ // go test is not good about reporting the start and end of benchmarks
285
+ // so we'll synthesize those events to make life easier.
286
+ if ( ! msg . Test ?. startsWith ( 'Benchmark' ) ) {
287
+ return ;
290
288
}
289
+ if ( msg . Output === `=== RUN ${ msg . Test } \n` ) {
290
+ // === RUN BenchmarkFooBar
291
+ msg . Action = 'run' ;
292
+ } else if (
293
+ msg . Output ?. match ( / ^ (?< name > B e n c h m a r k [ / \w ] + ) - (?< procs > \d + ) \s + (?< result > .* ) (?: $ | \n ) / ) ?. [ 1 ] === msg . Test
294
+ ) {
295
+ // BenchmarkFooBar-4 123456 123.4 ns/op 123 B/op 12 allocs/op
296
+ msg . Action = 'pass' ;
297
+ } else {
298
+ return ;
299
+ }
300
+ }
291
301
302
+ switch ( msg . Action ) {
292
303
case 'run' :
293
304
case 'start' :
294
305
if ( ! msg . Test ) {
0 commit comments