Skip to content

Commit c2f720d

Browse files
authored
Merge pull request #102 from sarveshtamba/swift-5.1-branch
[test] Make swiftpm test robust against host triple differences
2 parents 0d3d9ac + 47d497e commit c2f720d

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import PackageModel
1616
import Basic
1717
import SPMUtility
1818
import SKTestSupport
19+
import Build
1920
import XCTest
2021

2122
final class SwiftPMWorkspaceTests: XCTestCase {
@@ -111,11 +112,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {
111112

112113
check("-target", arguments: arguments) // Only one!
113114
#if os(macOS)
114-
check("-target", "x86_64-apple-macosx10.10", arguments: arguments)
115+
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.10"), arguments: arguments)
115116
check("-sdk", arguments: arguments)
116117
check("-F", arguments: arguments)
117118
#else
118-
check("-target", "x86_64-unknown-linux", arguments: arguments)
119+
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
119120
#endif
120121

121122
check("-I", build.pathString, arguments: arguments)
@@ -334,11 +335,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {
334335
checkNot("-arch", arguments: arguments)
335336
check("-target", arguments: arguments) // Only one!
336337
#if os(macOS)
337-
check("-target", "x86_64-apple-macosx10.10", arguments: arguments)
338+
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.10"), arguments: arguments)
338339
check("-isysroot", arguments: arguments)
339340
check("-F", arguments: arguments)
340341
#else
341-
check("-target", "x86_64-unknown-linux", arguments: arguments)
342+
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
342343
#endif
343344

344345
check("-I", packageRoot.appending(components: "Sources", "lib", "include").pathString,
@@ -387,9 +388,9 @@ final class SwiftPMWorkspaceTests: XCTestCase {
387388
let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
388389
check("-target", arguments: arguments) // Only one!
389390
#if os(macOS)
390-
check("-target", "x86_64-apple-macosx10.13", arguments: arguments)
391+
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.13"), arguments: arguments)
391392
#else
392-
check("-target", "x86_64-unknown-linux", arguments: arguments)
393+
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
393394
#endif
394395
}
395396
}
@@ -430,18 +431,6 @@ private func buildPath(
430431
root: AbsolutePath,
431432
config: BuildSetup = TestSourceKitServer.buildSetup) -> AbsolutePath
432433
{
433-
let buildConfig = "\(config.configuration)"
434-
if let absoluteBuildPath = config.path {
435-
#if os(macOS)
436-
return absoluteBuildPath.appending(components: "x86_64-apple-macosx", buildConfig)
437-
#else
438-
return absoluteBuildPath.appending(components: "x86_64-unknown-linux", buildConfig)
439-
#endif
440-
} else {
441-
#if os(macOS)
442-
return root.appending(components: ".build", "x86_64-apple-macosx", buildConfig)
443-
#else
444-
return root.appending(components: ".build", "x86_64-unknown-linux", buildConfig)
445-
#endif
446-
}
434+
let buildPath = config.path ?? root.appending(component: ".build")
435+
return buildPath.appending(components: Triple.hostTriple.tripleString, "\(config.configuration)")
447436
}

0 commit comments

Comments
 (0)