@@ -996,22 +996,9 @@ suite("DiagnosticsManager Test Suite", async function () {
996996
997997 test ( "Provides swift diagnostics" , async ( ) => {
998998 // Build for indexing
999- let task = createBuildAllTask ( folderContext ) ;
999+ const task = createBuildAllTask ( folderContext ) ;
10001000 await executeTaskAndWaitForResult ( task ) ;
10011001
1002- // Open file
1003- const promise = Promise . resolve ( ) ; // waitForDiagnostics([mainUri], false);
1004- const document = await vscode . workspace . openTextDocument ( mainUri ) ;
1005- await vscode . languages . setTextDocumentLanguage ( document , "swift" ) ;
1006- await vscode . window . showTextDocument ( document ) ;
1007-
1008- task = createBuildAllTask ( folderContext ) ;
1009- await executeTaskAndWaitForResult ( task ) ;
1010-
1011- // Retrigger diagnostics
1012- await workspaceContext . focusFolder ( folderContext ) ;
1013- await promise ;
1014-
10151002 const lspSource = toolchain . swiftVersion . isGreaterThanOrEqual ( new Version ( 6 , 0 , 0 ) )
10161003 ? "SourceKit"
10171004 : "sourcekitd" ;
@@ -1023,7 +1010,6 @@ suite("DiagnosticsManager Test Suite", async function () {
10231010 vscode . DiagnosticSeverity . Warning
10241011 ) ;
10251012 expectedDiagnostic1 . source = lspSource ; // Set by LSP
1026- assertHasDiagnostic ( mainUri , expectedDiagnostic1 ) ;
10271013
10281014 // Include error
10291015 const expectedDiagnostic2 = new vscode . Diagnostic (
@@ -1032,6 +1018,20 @@ suite("DiagnosticsManager Test Suite", async function () {
10321018 vscode . DiagnosticSeverity . Error
10331019 ) ;
10341020 expectedDiagnostic2 . source = lspSource ; // Set by LSP
1021+
1022+ // Open file
1023+ const promise = waitForDiagnostics ( {
1024+ [ mainUri . fsPath ] : [ expectedDiagnostic1 , expectedDiagnostic2 ] ,
1025+ } ) ;
1026+ const document = await vscode . workspace . openTextDocument ( mainUri ) ;
1027+ await vscode . languages . setTextDocumentLanguage ( document , "swift" ) ;
1028+ await vscode . window . showTextDocument ( document ) ;
1029+
1030+ // Retrigger diagnostics
1031+ await workspaceContext . focusFolder ( folderContext ) ;
1032+ await promise ;
1033+
1034+ assertHasDiagnostic ( mainUri , expectedDiagnostic1 ) ;
10351035 assertHasDiagnostic ( mainUri , expectedDiagnostic2 ) ;
10361036 } ) . timeout ( 2 * 60 * 1000 ) ; // Allow 2 minutes to build
10371037
@@ -1040,23 +1040,13 @@ suite("DiagnosticsManager Test Suite", async function () {
10401040 const task = createBuildAllTask ( cFolderContext ) ;
10411041 await executeTaskAndWaitForResult ( task ) ;
10421042
1043- // Open file
1044- const promise = Promise . resolve ( ) ; // waitForDiagnostics([cUri], false);
1045- const document = await vscode . workspace . openTextDocument ( cUri ) ;
1046- await vscode . languages . setTextDocumentLanguage ( document , "c" ) ;
1047- await vscode . window . showTextDocument ( document ) ;
1048-
1049- // Retrigger diagnostics
1050- await workspaceContext . focusFolder ( cFolderContext ) ;
1051- await promise ;
1052-
1043+ // No string manipulation
10531044 const expectedDiagnostic1 = new vscode . Diagnostic (
10541045 new vscode . Range ( new vscode . Position ( 5 , 10 ) , new vscode . Position ( 5 , 13 ) ) ,
10551046 "Use of undeclared identifier 'bar'" ,
10561047 vscode . DiagnosticSeverity . Error
10571048 ) ;
10581049 expectedDiagnostic1 . source = "clang" ; // Set by LSP
1059- assertHasDiagnostic ( cUri , expectedDiagnostic1 ) ;
10601050
10611051 // Remove "(fix available)" from string from SourceKit
10621052 const expectedDiagnostic2 = new vscode . Diagnostic (
@@ -1065,6 +1055,20 @@ suite("DiagnosticsManager Test Suite", async function () {
10651055 vscode . DiagnosticSeverity . Error
10661056 ) ;
10671057 expectedDiagnostic2 . source = "clang" ; // Set by LSP
1058+
1059+ // Open file
1060+ const promise = waitForDiagnostics ( {
1061+ [ cUri . fsPath ] : [ expectedDiagnostic1 , expectedDiagnostic2 ] ,
1062+ } ) ;
1063+ const document = await vscode . workspace . openTextDocument ( cUri ) ;
1064+ await vscode . languages . setTextDocumentLanguage ( document , "c" ) ;
1065+ await vscode . window . showTextDocument ( document ) ;
1066+
1067+ // Retrigger diagnostics
1068+ await workspaceContext . focusFolder ( cFolderContext ) ;
1069+ await promise ;
1070+
1071+ assertHasDiagnostic ( cUri , expectedDiagnostic1 ) ;
10681072 assertHasDiagnostic ( cUri , expectedDiagnostic2 ) ;
10691073 } ) . timeout ( 2 * 60 * 1000 ) ; // Allow 2 minutes to build
10701074 } ) ;
0 commit comments