@@ -32,8 +32,7 @@ import {
32
32
} from "./utilities/testutilities" ;
33
33
import { DiagnosticStyle } from "../../src/configuration" ;
34
34
import { expect } from "chai" ;
35
- import { touchDocument , waitForClientState } from "./utilities/lsputilities" ;
36
- import { LanguageClientManager } from "../../src/sourcekit-lsp/LanguageClientManager" ;
35
+ import { touchDocument , waitForClientState , waitForIndex } from "./utilities/lsputilities" ;
37
36
38
37
const isEqual = ( d1 : vscode . Diagnostic , d2 : vscode . Diagnostic ) => {
39
38
return (
@@ -1188,7 +1187,8 @@ suite("DiagnosticsManager Test Suite", function () {
1188
1187
} ) ;
1189
1188
1190
1189
suiteSetup ( async function ( ) {
1191
- if ( workspaceContext . globalToolchainSwiftVersion . isLessThan ( new Version ( 5 , 9 , 0 ) ) ) {
1190
+ if ( workspaceContext . globalToolchainSwiftVersion . isLessThan ( new Version ( 6 , 0 , 0 ) ) ) {
1191
+ // need to waitForIndex
1192
1192
this . skip ( ) ;
1193
1193
return ;
1194
1194
}
@@ -1201,16 +1201,19 @@ suite("DiagnosticsManager Test Suite", function () {
1201
1201
await vscode . commands . executeCommand ( Workbench . ACTION_CLOSEALLEDITORS ) ;
1202
1202
} ) ;
1203
1203
1204
- suite ( "swift" , ( ) => {
1205
- let clientManager : LanguageClientManager ;
1204
+ async function triggerFileDiagnostics ( uri : vscode . Uri , folder : FolderContext ) {
1205
+ const clientManager = workspaceContext . languageClientManager . get ( folder ) ;
1206
+ await waitForClientState ( clientManager , langclient . State . Running ) ;
1207
+ await vscode . window . showTextDocument ( uri ) ;
1208
+ await new Promise ( r => setTimeout ( r , 2000 ) ) ;
1209
+ await touchDocument ( clientManager , uri ) ;
1210
+ await waitForIndex ( clientManager , folder . swiftVersion ) ;
1211
+ }
1206
1212
1213
+ suite ( "swift" , ( ) => {
1207
1214
setup ( async function ( ) {
1208
1215
this . timeout ( 3 * 60 * 1000 ) ; // Allow 3 minutes to build
1209
- const folder = await buildProject ( workspaceContext , "diagnostics" , true ) ;
1210
- // Ensure lsp client is ready
1211
- clientManager = workspaceContext . languageClientManager . get ( folder ) ;
1212
- await clientManager . restart ( ) ;
1213
- await waitForClientState ( clientManager , langclient . State . Running ) ;
1216
+ await buildProject ( workspaceContext , "diagnostics" , true ) ;
1214
1217
} ) ;
1215
1218
1216
1219
test ( "Provides diagnostics" , async ( ) => {
@@ -1234,28 +1237,19 @@ suite("DiagnosticsManager Test Suite", function () {
1234
1237
) ;
1235
1238
expectedDiagnostic2 . source = lspSource ; // Set by LSP
1236
1239
1237
- // Open file
1238
1240
const promise = waitForDiagnostics ( {
1239
1241
[ mainUri . fsPath ] : [ expectedDiagnostic1 , expectedDiagnostic2 ] ,
1240
1242
} ) ;
1241
- await vscode . window . showTextDocument ( mainUri ) ;
1242
- await touchDocument ( clientManager , mainUri ) ;
1243
-
1244
1243
// Retrigger diagnostics
1244
+ await triggerFileDiagnostics ( mainUri , folderContext ) ;
1245
1245
await promise ;
1246
1246
} ) ;
1247
1247
} ) ;
1248
1248
1249
1249
suite ( "clang" , async ( ) => {
1250
- let clientManager : LanguageClientManager ;
1251
-
1252
1250
setup ( async function ( ) {
1253
1251
this . timeout ( 3 * 60 * 1000 ) ; // Allow 3 minutes to build
1254
- const folder = await buildProject ( workspaceContext , "diagnosticsC" , true ) ;
1255
- // Ensure lsp client is ready
1256
- clientManager = workspaceContext . languageClientManager . get ( folder ) ;
1257
- await clientManager . restart ( ) ;
1258
- await waitForClientState ( clientManager , langclient . State . Running ) ;
1252
+ await buildProject ( workspaceContext , "diagnosticsC" , true ) ;
1259
1253
} ) ;
1260
1254
1261
1255
test ( "Provides diagnostics" , async ( ) => {
@@ -1275,14 +1269,11 @@ suite("DiagnosticsManager Test Suite", function () {
1275
1269
) ;
1276
1270
expectedDiagnostic2 . source = "clang" ; // Set by LSP
1277
1271
1278
- // Open file
1279
1272
const promise = waitForDiagnostics ( {
1280
1273
[ cUri . fsPath ] : [ expectedDiagnostic1 , expectedDiagnostic2 ] ,
1281
1274
} ) ;
1282
- await vscode . window . showTextDocument ( cUri ) ;
1283
- await touchDocument ( clientManager , cUri ) ;
1284
-
1285
1275
// Retrigger diagnostics
1276
+ await triggerFileDiagnostics ( cUri , cFolderContext ) ;
1286
1277
await promise ;
1287
1278
} ) ;
1288
1279
} ) ;
0 commit comments