@@ -996,22 +996,9 @@ suite("DiagnosticsManager Test Suite", async function () {
996
996
997
997
test ( "Provides swift diagnostics" , async ( ) => {
998
998
// Build for indexing
999
- let task = createBuildAllTask ( folderContext ) ;
999
+ const task = createBuildAllTask ( folderContext ) ;
1000
1000
await executeTaskAndWaitForResult ( task ) ;
1001
1001
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
-
1015
1002
const lspSource = toolchain . swiftVersion . isGreaterThanOrEqual ( new Version ( 6 , 0 , 0 ) )
1016
1003
? "SourceKit"
1017
1004
: "sourcekitd" ;
@@ -1023,7 +1010,6 @@ suite("DiagnosticsManager Test Suite", async function () {
1023
1010
vscode . DiagnosticSeverity . Warning
1024
1011
) ;
1025
1012
expectedDiagnostic1 . source = lspSource ; // Set by LSP
1026
- assertHasDiagnostic ( mainUri , expectedDiagnostic1 ) ;
1027
1013
1028
1014
// Include error
1029
1015
const expectedDiagnostic2 = new vscode . Diagnostic (
@@ -1032,6 +1018,20 @@ suite("DiagnosticsManager Test Suite", async function () {
1032
1018
vscode . DiagnosticSeverity . Error
1033
1019
) ;
1034
1020
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 ) ;
1035
1035
assertHasDiagnostic ( mainUri , expectedDiagnostic2 ) ;
1036
1036
} ) . timeout ( 2 * 60 * 1000 ) ; // Allow 2 minutes to build
1037
1037
@@ -1040,23 +1040,13 @@ suite("DiagnosticsManager Test Suite", async function () {
1040
1040
const task = createBuildAllTask ( cFolderContext ) ;
1041
1041
await executeTaskAndWaitForResult ( task ) ;
1042
1042
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
1053
1044
const expectedDiagnostic1 = new vscode . Diagnostic (
1054
1045
new vscode . Range ( new vscode . Position ( 5 , 10 ) , new vscode . Position ( 5 , 13 ) ) ,
1055
1046
"Use of undeclared identifier 'bar'" ,
1056
1047
vscode . DiagnosticSeverity . Error
1057
1048
) ;
1058
1049
expectedDiagnostic1 . source = "clang" ; // Set by LSP
1059
- assertHasDiagnostic ( cUri , expectedDiagnostic1 ) ;
1060
1050
1061
1051
// Remove "(fix available)" from string from SourceKit
1062
1052
const expectedDiagnostic2 = new vscode . Diagnostic (
@@ -1065,6 +1055,20 @@ suite("DiagnosticsManager Test Suite", async function () {
1065
1055
vscode . DiagnosticSeverity . Error
1066
1056
) ;
1067
1057
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 ) ;
1068
1072
assertHasDiagnostic ( cUri , expectedDiagnostic2 ) ;
1069
1073
} ) . timeout ( 2 * 60 * 1000 ) ; // Allow 2 minutes to build
1070
1074
} ) ;
0 commit comments