mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Wait for indexstore-db to update after building a SwiftPM project in tests
Otherwise we can get into race conditions where we run a request before the index has actually been updated. While at it, also add logging when IndexStoreDB has been updated. rdar://126635046
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
import Dispatch
|
||||
import IndexStoreDB
|
||||
import LSPLogging
|
||||
import SKCore
|
||||
import SKSupport
|
||||
|
||||
@@ -62,6 +63,7 @@ public actor SourceKitIndexDelegate: IndexDelegate {
|
||||
}
|
||||
|
||||
private func indexChanged() {
|
||||
logger.debug("IndexStoreDB changed")
|
||||
for callback in mainFilesChangedCallbacks {
|
||||
queue.async {
|
||||
await callback()
|
||||
|
||||
@@ -584,7 +584,7 @@ final class RenameTests: XCTestCase {
|
||||
name: "MyLibrary",
|
||||
targets: [
|
||||
.target(
|
||||
name: "MyLibrary",
|
||||
name: "MyLibrary",
|
||||
swiftSettings: [.unsafeFlags(["-Xfrontend", "-disable-objc-attr-requires-foundation-module"])]
|
||||
)
|
||||
]
|
||||
@@ -635,7 +635,7 @@ final class RenameTests: XCTestCase {
|
||||
name: "MyLibrary",
|
||||
targets: [
|
||||
.target(
|
||||
name: "MyLibrary",
|
||||
name: "MyLibrary",
|
||||
swiftSettings: [.unsafeFlags(["-Xfrontend", "-disable-objc-attr-requires-foundation-module"])]
|
||||
)
|
||||
]
|
||||
@@ -1158,6 +1158,7 @@ final class RenameTests: XCTestCase {
|
||||
)
|
||||
|
||||
try await SwiftPMTestProject.build(at: project.scratchDirectory)
|
||||
_ = try await project.testClient.send(PollIndexRequest())
|
||||
|
||||
let resultAfterFileMove = try await project.testClient.send(
|
||||
RenameRequest(textDocument: TextDocumentIdentifier(callerUri), position: callerPositions["3️⃣"], newName: "bar")
|
||||
|
||||
@@ -247,6 +247,7 @@ final class TestDiscoveryTests: XCTestCase {
|
||||
)
|
||||
|
||||
try await SwiftPMTestProject.build(at: project.scratchDirectory)
|
||||
_ = try await project.testClient.send(PollIndexRequest())
|
||||
|
||||
// After indexing, we know that `LooksLikeTestCaseButIsNot` does not inherit from `XCTestCase` and we don't report any tests.
|
||||
let indexBasedTests = try await project.testClient.send(
|
||||
|
||||
Reference in New Issue
Block a user