Skip to content

Commit 2aefb57

Browse files
committed
Change main file tests to define sources inline
The tests are structured quite differently now but I think the new, smaller test cases cover all the interesting cases from the old test.
1 parent 9cd33a6 commit 2aefb57

File tree

12 files changed

+199
-177
lines changed

12 files changed

+199
-177
lines changed

Sources/SKTestSupport/INPUTS/MainFiles/a.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/b.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/bridging.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/c.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/d.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/project.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/shared.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

Sources/SKTestSupport/INPUTS/MainFiles/unique.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

Sources/SKTestSupport/MultiFileTestWorkspace.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ public class MultiFileTestWorkspace {
113113
/// Opens the document with the given file name in the SourceKit-LSP server.
114114
///
115115
/// - Returns: The URI for the opened document and the positions of the location markers.
116-
public func openDocument(_ fileName: String) throws -> (uri: DocumentURI, positions: DocumentPositions) {
116+
public func openDocument(_ fileName: String, language: Language? = nil) throws -> (
117+
uri: DocumentURI, positions: DocumentPositions
118+
) {
117119
guard let fileData = self.fileData[fileName] else {
118120
throw Error.fileNotFound
119121
}
120-
let positions = testClient.openDocument(fileData.markedText, uri: fileData.uri)
122+
let positions = testClient.openDocument(fileData.markedText, uri: fileData.uri, language: language)
121123
return (fileData.uri, positions)
122124
}
123125

Sources/SKTestSupport/SwiftPMTestWorkspace.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public class SwiftPMTestWorkspace: MultiFileTestWorkspace {
7878
"-Xswiftc", "-index-ignore-system-modules",
7979
"-Xcc", "-index-ignore-system-symbols",
8080
]
81-
try await Process.checkNonZeroExit(arguments: arguments)
81+
var environment = ProcessEnv.vars
82+
// FIXME: SwiftPM does not index-while-building on non-Darwin platforms for C-family files (rdar://117744039).
83+
// Force-enable index-while-building with the environment variable.
84+
environment["SWIFTPM_ENABLE_CLANG_INDEX_STORE"] = "1"
85+
try await Process.checkNonZeroExit(arguments: arguments, environment: environment)
8286
}
8387
}

0 commit comments

Comments
 (0)