Skip to content

Commit b3b65a2

Browse files
committed
Use Windows file paths for fake output paths
1 parent c632e47 commit b3b65a2

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

Sources/SKTestSupport/CustomBuildServerTestProject.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ package extension CustomBuildServer {
135135
)
136136
}
137137

138+
/// Returns a fake path that is unique to this target and file combination and can be used to identify this
139+
/// combination in a unit's output path.
140+
func fakeOutputPath(for file: String, in target: String) -> String {
141+
#if os(Windows)
142+
return #"C:\"# + target + #"\"# + file + ".o"
143+
#else
144+
return "/" + target + "/" + file + ".o"
145+
#endif
146+
}
147+
138148
func sourceItem(for url: URL, outputPath: String) -> SourceItem {
139149
SourceItem(
140150
uri: URI(url),

Sources/SemanticIndex/CheckedIndex.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,8 @@ private struct IndexOutOfDateChecker {
522522
// updated.
523523
while let relativeSymlinkDestination = try? FileManager.default.destinationOfSymbolicLink(
524524
atPath: fileURL.filePath
525-
),
526-
let symlinkDestination = URL(string: relativeSymlinkDestination, relativeTo: fileURL)
527-
{
528-
fileURL = symlinkDestination
525+
) {
526+
fileURL = URL(fileURLWithPath: relativeSymlinkDestination, relativeTo: fileURL)
529527
modificationDate = max(modificationDate, try Self.modificationDate(atPath: fileURL.filePath))
530528
}
531529

Tests/SourceKitLSPTests/BackgroundIndexingTests.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,15 +2185,27 @@ final class BackgroundIndexingTests: XCTestCase {
21852185
SourcesItem(
21862186
target: libATarget,
21872187
sources: [
2188-
sourceItem(for: projectRoot.appendingPathComponent("Shared.swift"), outputPath: "/LibA/Shared.swift.o"),
2189-
sourceItem(for: projectRoot.appendingPathComponent("LibA.swift"), outputPath: "/LibA/LibA.swift.o"),
2188+
sourceItem(
2189+
for: projectRoot.appendingPathComponent("Shared.swift"),
2190+
outputPath: fakeOutputPath(for: "Shared.swift", in: "LibA")
2191+
),
2192+
sourceItem(
2193+
for: projectRoot.appendingPathComponent("LibA.swift"),
2194+
outputPath: fakeOutputPath(for: "LibA.swift", in: "LibA")
2195+
),
21902196
]
21912197
),
21922198
SourcesItem(
21932199
target: libBTarget,
21942200
sources: [
2195-
sourceItem(for: projectRoot.appendingPathComponent("Shared.swift"), outputPath: "/LibB/Shared.swift.o"),
2196-
sourceItem(for: projectRoot.appendingPathComponent("LibB.swift"), outputPath: "/LibB/LibB.swift.o"),
2201+
sourceItem(
2202+
for: projectRoot.appendingPathComponent("Shared.swift"),
2203+
outputPath: fakeOutputPath(for: "Shared.swift", in: "LibB")
2204+
),
2205+
sourceItem(
2206+
for: projectRoot.appendingPathComponent("LibB.swift"),
2207+
outputPath: fakeOutputPath(for: "LibB.swift", in: "LibB")
2208+
),
21972209
]
21982210
),
21992211
]
@@ -2289,13 +2301,19 @@ final class BackgroundIndexingTests: XCTestCase {
22892301
SourcesItem(
22902302
target: libATarget,
22912303
sources: [
2292-
sourceItem(for: projectRoot.appendingPathComponent("LibA.c"), outputPath: "/LibA/LibA.c.o")
2304+
sourceItem(
2305+
for: projectRoot.appendingPathComponent("LibA.c"),
2306+
outputPath: fakeOutputPath(for: "LibA.c", in: "LibA")
2307+
)
22932308
]
22942309
),
22952310
SourcesItem(
22962311
target: libBTarget,
22972312
sources: [
2298-
sourceItem(for: projectRoot.appendingPathComponent("LibB.c"), outputPath: "/LibB/LibB.c.o")
2313+
sourceItem(
2314+
for: projectRoot.appendingPathComponent("LibB.c"),
2315+
outputPath: fakeOutputPath(for: "LibB.c", in: "LibB")
2316+
)
22992317
]
23002318
),
23012319
]

0 commit comments

Comments
 (0)