@@ -9,6 +9,9 @@ import * as main from '../src/main';
9
9
import * as im from '../src/installer' ;
10
10
11
11
let goJsonData = require ( './data/golang-dl.json' ) ;
12
+ let matchers = require ( '../matchers.json' ) ;
13
+ let matcherPattern = matchers . problemMatcher [ 0 ] . pattern [ 0 ] ;
14
+ let matcherRegExp = new RegExp ( matcherPattern . regexp ) ;
12
15
13
16
describe ( 'setup-go' , ( ) => {
14
17
let inputs = { } as any ;
@@ -322,6 +325,100 @@ describe('setup-go', () => {
322
325
expect ( added ) . toBeTruthy ;
323
326
} ) ;
324
327
328
+ interface Annotation {
329
+ file : string ;
330
+ line : number ;
331
+ column : number ;
332
+ message : string ;
333
+ }
334
+
335
+ //
336
+ // problem matcher regex pattern tests
337
+
338
+ function testMatch ( line : string ) : Annotation {
339
+ let annotation = < Annotation > { } ;
340
+
341
+ let match = matcherRegExp . exec ( line ) ;
342
+ if ( match ) {
343
+ annotation . line = parseInt ( match [ matcherPattern . line ] , 10 ) ;
344
+ annotation . column = parseInt ( match [ matcherPattern . column ] , 10 ) ;
345
+ annotation . file = match [ matcherPattern . file ] . trim ( ) ;
346
+ annotation . message = match [ matcherPattern . message ] . trim ( ) ;
347
+ }
348
+
349
+ return annotation ;
350
+ }
351
+
352
+ it ( 'matches on relative unix path' , async ( ) => {
353
+ let line = './main.go:13:2: undefined: fmt.Printl' ;
354
+ let annotation = testMatch ( line ) ;
355
+ expect ( annotation ) . toBeDefined ( ) ;
356
+ expect ( annotation . line ) . toBe ( 13 ) ;
357
+ expect ( annotation . column ) . toBe ( 2 ) ;
358
+ expect ( annotation . file ) . toBe ( './main.go' ) ;
359
+ expect ( annotation . message ) . toBe ( 'undefined: fmt.Printl' ) ;
360
+ } ) ;
361
+
362
+ it ( 'matches on unix path up the tree' , async ( ) => {
363
+ let line = '../main.go:13:2: undefined: fmt.Printl' ;
364
+ let annotation = testMatch ( line ) ;
365
+ expect ( annotation ) . toBeDefined ( ) ;
366
+ expect ( annotation . line ) . toBe ( 13 ) ;
367
+ expect ( annotation . column ) . toBe ( 2 ) ;
368
+ expect ( annotation . file ) . toBe ( '../main.go' ) ;
369
+ expect ( annotation . message ) . toBe ( 'undefined: fmt.Printl' ) ;
370
+ } ) ;
371
+
372
+ it ( 'matches on rooted unix path' , async ( ) => {
373
+ let line = '/assert.go:4:1: missing return at end of function' ;
374
+ let annotation = testMatch ( line ) ;
375
+ expect ( annotation ) . toBeDefined ( ) ;
376
+ expect ( annotation . line ) . toBe ( 4 ) ;
377
+ expect ( annotation . column ) . toBe ( 1 ) ;
378
+ expect ( annotation . file ) . toBe ( '/assert.go' ) ;
379
+ expect ( annotation . message ) . toBe ( 'missing return at end of function' ) ;
380
+ } ) ;
381
+
382
+ it ( 'matches on unix path with spaces' , async ( ) => {
383
+ let line = ' ./assert.go:5:2: missing return at end of function ' ;
384
+ let annotation = testMatch ( line ) ;
385
+ expect ( annotation ) . toBeDefined ( ) ;
386
+ expect ( annotation . line ) . toBe ( 5 ) ;
387
+ expect ( annotation . column ) . toBe ( 2 ) ;
388
+ expect ( annotation . file ) . toBe ( './assert.go' ) ;
389
+ expect ( annotation . message ) . toBe ( 'missing return at end of function' ) ;
390
+ } ) ;
391
+
392
+ it ( 'matches on unix path with tabs' , async ( ) => {
393
+ let line = '\t./assert.go:5:2: missing return at end of function ' ;
394
+ let annotation = testMatch ( line ) ;
395
+ expect ( annotation ) . toBeDefined ( ) ;
396
+ expect ( annotation . line ) . toBe ( 5 ) ;
397
+ expect ( annotation . column ) . toBe ( 2 ) ;
398
+ expect ( annotation . file ) . toBe ( './assert.go' ) ;
399
+ expect ( annotation . message ) . toBe ( 'missing return at end of function' ) ;
400
+ } ) ;
401
+
402
+ it ( 'matches on relative windows path' , async ( ) => {
403
+ let line = '.\\main.go:13:2: undefined: fmt.Printl' ;
404
+ let annotation = testMatch ( line ) ;
405
+ expect ( annotation ) . toBeDefined ( ) ;
406
+ expect ( annotation . line ) . toBe ( 13 ) ;
407
+ expect ( annotation . column ) . toBe ( 2 ) ;
408
+ expect ( annotation . file ) . toBe ( '.\\main.go' ) ;
409
+ expect ( annotation . message ) . toBe ( 'undefined: fmt.Printl' ) ;
410
+ } ) ;
411
+
412
+ it ( 'matches on windows path up the tree' , async ( ) => {
413
+ let line = '..\\main.go:13:2: undefined: fmt.Printl' ;
414
+ let annotation = testMatch ( line ) ;
415
+ expect ( annotation ) . toBeDefined ( ) ;
416
+ expect ( annotation . line ) . toBe ( 13 ) ;
417
+ expect ( annotation . column ) . toBe ( 2 ) ;
418
+ expect ( annotation . file ) . toBe ( '..\\main.go' ) ;
419
+ expect ( annotation . message ) . toBe ( 'undefined: fmt.Printl' ) ;
420
+ } ) ;
421
+
325
422
// 1.13.1 => 1.13.1
326
423
// 1.13 => 1.13.0
327
424
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
0 commit comments