@@ -436,40 +436,45 @@ It returns the number of bytes written and any write error encountered.
436
436
} ) ;
437
437
438
438
test ( 'Linting - lint errors with multiple open files' , async ( ) => {
439
- // handleDiagnosticErrors may adjust the lint errors' ranges to make the error more visible.
440
- // This adjustment applies only to the text documents known to vscode. This test checks
441
- // the adjustment is made consistently across multiple open text documents.
442
- const file1 = await vscode . workspace . openTextDocument (
443
- vscode . Uri . file ( path . join ( fixturePath , 'linterTest' , 'linter_1.go' ) )
444
- ) ;
445
- const file2 = await vscode . workspace . openTextDocument (
446
- vscode . Uri . file ( path . join ( fixturePath , 'linterTest' , 'linter_2.go' ) )
447
- ) ;
448
- const warnings = await goLint (
449
- file2 . uri ,
450
- Object . create ( getGoConfig ( ) , {
451
- lintTool : { value : 'staticcheck' } ,
452
- lintFlags : { value : [ '-checks' , 'all,-ST1000,-ST1016' ] }
453
- // staticcheck skips debatable checks such as ST1003 by default,
454
- // but this test depends on ST1003 (MixedCaps package name) presented in both files
455
- // in the same package. So, enable that.
456
- } ) ,
457
- Object . create ( getGoplsConfig ( ) , { } ) ,
458
- 'package'
459
- ) ;
439
+ try {
440
+ // handleDiagnosticErrors may adjust the lint errors' ranges to make the error more visible.
441
+ // This adjustment applies only to the text documents known to vscode. This test checks
442
+ // the adjustment is made consistently across multiple open text documents.
443
+ const file1 = await vscode . workspace . openTextDocument (
444
+ vscode . Uri . file ( path . join ( fixturePath , 'linterTest' , 'linter_1.go' ) )
445
+ ) ;
446
+ const file2 = await vscode . workspace . openTextDocument (
447
+ vscode . Uri . file ( path . join ( fixturePath , 'linterTest' , 'linter_2.go' ) )
448
+ ) ;
449
+ console . log ( 'start linting' ) ;
450
+ const warnings = await goLint (
451
+ file2 . uri ,
452
+ Object . create ( getGoConfig ( ) , {
453
+ lintTool : { value : 'staticcheck' } ,
454
+ lintFlags : { value : [ '-checks' , 'all,-ST1000,-ST1016' ] }
455
+ // staticcheck skips debatable checks such as ST1003 by default,
456
+ // but this test depends on ST1003 (MixedCaps package name) presented in both files
457
+ // in the same package. So, enable that.
458
+ } ) ,
459
+ Object . create ( getGoplsConfig ( ) , { } ) ,
460
+ 'package'
461
+ ) ;
460
462
461
- const diagnosticCollection = vscode . languages . createDiagnosticCollection ( 'linttest' ) ;
462
- handleDiagnosticErrors ( { } , file2 , warnings , diagnosticCollection ) ;
463
-
464
- // The first diagnostic message for each file should be about the use of MixedCaps in package name.
465
- // Both files belong to the same package name, and we want them to be identical.
466
- const file1Diagnostics = diagnosticCollection . get ( file1 . uri ) ;
467
- const file2Diagnostics = diagnosticCollection . get ( file2 . uri ) ;
468
- assert ( file1Diagnostics ) ;
469
- assert ( file2Diagnostics ) ;
470
- assert ( file1Diagnostics . length > 0 ) ;
471
- assert ( file2Diagnostics . length > 0 ) ;
472
- assert . deepStrictEqual ( file1Diagnostics [ 0 ] , file2Diagnostics [ 0 ] ) ;
463
+ const diagnosticCollection = vscode . languages . createDiagnosticCollection ( 'linttest' ) ;
464
+ handleDiagnosticErrors ( { } , file2 , warnings , diagnosticCollection ) ;
465
+
466
+ // The first diagnostic message for each file should be about the use of MixedCaps in package name.
467
+ // Both files belong to the same package name, and we want them to be identical.
468
+ const file1Diagnostics = diagnosticCollection . get ( file1 . uri ) ;
469
+ const file2Diagnostics = diagnosticCollection . get ( file2 . uri ) ;
470
+ assert ( file1Diagnostics ) ;
471
+ assert ( file2Diagnostics ) ;
472
+ assert ( file1Diagnostics . length > 0 ) ;
473
+ assert ( file2Diagnostics . length > 0 ) ;
474
+ assert . deepStrictEqual ( file1Diagnostics [ 0 ] , file2Diagnostics [ 0 ] ) ;
475
+ } catch ( e ) {
476
+ assert . fail ( `failed to lint: ${ e } ` ) ;
477
+ }
473
478
} ) ;
474
479
475
480
test ( 'Error checking' , async ( ) => {
0 commit comments