14
14
import Foundation
15
15
import LanguageServerProtocol
16
16
import SKTestSupport
17
+ import SemanticIndex
17
18
@_spi ( Testing) import SourceKitLSP
18
19
import SwiftExtensions
19
20
import ToolchainRegistry
@@ -113,6 +114,9 @@ final class WorkspaceTestDiscoveryTests: XCTestCase {
113
114
func testSyntacticOrIndexBasedXCTestsBasedOnWhetherFileIsIndexed( ) async throws {
114
115
try SkipUnless . longTestsEnabled ( )
115
116
117
+ let initialIndexingFinished = AtomicBool ( initialValue: false )
118
+ let syntacticWorkspaceRequestSent = WrappedSemaphore ( name: " Syntactic workspace request sent " )
119
+
116
120
let project = try await SwiftPMTestProject (
117
121
files: [
118
122
" Tests/MyLibraryTests/MyTests.swift " : """
@@ -126,9 +130,18 @@ final class WorkspaceTestDiscoveryTests: XCTestCase {
126
130
"""
127
131
] ,
128
132
manifest: packageManifestWithTestTarget,
133
+ hooks: Hooks (
134
+ indexHooks: IndexHooks ( updateIndexStoreTaskDidStart: { _ in
135
+ if initialIndexingFinished. value {
136
+ syntacticWorkspaceRequestSent. waitOrXCTFail ( )
137
+ }
138
+ } )
139
+ ) ,
129
140
enableBackgroundIndexing: true
130
141
)
131
142
143
+ initialIndexingFinished. value = true
144
+
132
145
let myTestsUri = try project. uri ( for: " MyTests.swift " )
133
146
134
147
// First get the tests from the original file contents, which are computed by the semantic index.
@@ -200,6 +213,8 @@ final class WorkspaceTestDiscoveryTests: XCTestCase {
200
213
]
201
214
)
202
215
216
+ syntacticWorkspaceRequestSent. signal ( )
217
+
203
218
// After building again, we should have updated the updated the semantic index and realize that `NotQuiteTests` does
204
219
// not inherit from XCTest and thus doesn't have any test methods.
205
220
0 commit comments