Skip to content

Commit 88b40f3

Browse files
committed
Use Windows file paths for fake output paths
1 parent 4991e15 commit 88b40f3

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
@@ -188,6 +188,16 @@ package extension CustomBuildServer {
188188
)
189189
}
190190

191+
/// Returns a fake path that is unique to this target and file combination and can be used to identify this
192+
/// combination in a unit's output path.
193+
func fakeOutputPath(for file: String, in target: String) -> String {
194+
#if os(Windows)
195+
return #"C:\"# + target + #"\"# + file + ".o"
196+
#else
197+
return "/" + target + "/" + file + ".o"
198+
#endif
199+
}
200+
191201
func sourceItem(for url: URL, outputPath: String) -> SourceItem {
192202
SourceItem(
193203
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
@@ -2292,15 +2292,27 @@ final class BackgroundIndexingTests: XCTestCase {
22922292
SourcesItem(
22932293
target: libATarget,
22942294
sources: [
2295-
sourceItem(for: projectRoot.appendingPathComponent("Shared.swift"), outputPath: "/LibA/Shared.swift.o"),
2296-
sourceItem(for: projectRoot.appendingPathComponent("LibA.swift"), outputPath: "/LibA/LibA.swift.o"),
2295+
sourceItem(
2296+
for: projectRoot.appendingPathComponent("Shared.swift"),
2297+
outputPath: fakeOutputPath(for: "Shared.swift", in: "LibA")
2298+
),
2299+
sourceItem(
2300+
for: projectRoot.appendingPathComponent("LibA.swift"),
2301+
outputPath: fakeOutputPath(for: "LibA.swift", in: "LibA")
2302+
),
22972303
]
22982304
),
22992305
SourcesItem(
23002306
target: libBTarget,
23012307
sources: [
2302-
sourceItem(for: projectRoot.appendingPathComponent("Shared.swift"), outputPath: "/LibB/Shared.swift.o"),
2303-
sourceItem(for: projectRoot.appendingPathComponent("LibB.swift"), outputPath: "/LibB/LibB.swift.o"),
2308+
sourceItem(
2309+
for: projectRoot.appendingPathComponent("Shared.swift"),
2310+
outputPath: fakeOutputPath(for: "Shared.swift", in: "LibB")
2311+
),
2312+
sourceItem(
2313+
for: projectRoot.appendingPathComponent("LibB.swift"),
2314+
outputPath: fakeOutputPath(for: "LibB.swift", in: "LibB")
2315+
),
23042316
]
23052317
),
23062318
]
@@ -2398,13 +2410,19 @@ final class BackgroundIndexingTests: XCTestCase {
23982410
SourcesItem(
23992411
target: libATarget,
24002412
sources: [
2401-
sourceItem(for: projectRoot.appendingPathComponent("LibA.c"), outputPath: "/LibA/LibA.c.o")
2413+
sourceItem(
2414+
for: projectRoot.appendingPathComponent("LibA.c"),
2415+
outputPath: fakeOutputPath(for: "LibA.c", in: "LibA")
2416+
)
24022417
]
24032418
),
24042419
SourcesItem(
24052420
target: libBTarget,
24062421
sources: [
2407-
sourceItem(for: projectRoot.appendingPathComponent("LibB.c"), outputPath: "/LibB/LibB.c.o")
2422+
sourceItem(
2423+
for: projectRoot.appendingPathComponent("LibB.c"),
2424+
outputPath: fakeOutputPath(for: "LibB.c", in: "LibB")
2425+
)
24082426
]
24092427
),
24102428
]

0 commit comments

Comments
 (0)