Skip to content

[test] Make swiftpm test robust against host triple differences #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PackageModel
import Basic
import SPMUtility
import SKTestSupport
import Build
import XCTest

final class SwiftPMWorkspaceTests: XCTestCase {
Expand Down Expand Up @@ -111,11 +112,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {

check("-target", arguments: arguments) // Only one!
#if os(macOS)
check("-target", "x86_64-apple-macosx10.10", arguments: arguments)
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.10"), arguments: arguments)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if due to this issue: https://twitter.com/jckarter/status/1095757933579689985 we shouldn't stick to minimum 10.11 on macOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this ever breaks we can change it, but this test won't try to generate code, so I think it's probably fine.

check("-sdk", arguments: arguments)
check("-F", arguments: arguments)
#else
check("-target", "x86_64-unknown-linux", arguments: arguments)
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
#endif

check("-I", build.pathString, arguments: arguments)
Expand Down Expand Up @@ -334,11 +335,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {
checkNot("-arch", arguments: arguments)
check("-target", arguments: arguments) // Only one!
#if os(macOS)
check("-target", "x86_64-apple-macosx10.10", arguments: arguments)
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.10"), arguments: arguments)
check("-isysroot", arguments: arguments)
check("-F", arguments: arguments)
#else
check("-target", "x86_64-unknown-linux", arguments: arguments)
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
#endif

check("-I", packageRoot.appending(components: "Sources", "lib", "include").pathString,
Expand Down Expand Up @@ -387,9 +388,9 @@ final class SwiftPMWorkspaceTests: XCTestCase {
let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
check("-target", arguments: arguments) // Only one!
#if os(macOS)
check("-target", "x86_64-apple-macosx10.13", arguments: arguments)
check("-target", Triple.hostTriple.tripleString(forPlatformVersion: "10.13"), arguments: arguments)
#else
check("-target", "x86_64-unknown-linux", arguments: arguments)
check("-target", Triple.hostTriple.tripleString, arguments: arguments)
#endif
}
}
Expand Down Expand Up @@ -430,18 +431,6 @@ private func buildPath(
root: AbsolutePath,
config: BuildSetup = TestSourceKitServer.buildSetup) -> AbsolutePath
{
let buildConfig = "\(config.configuration)"
if let absoluteBuildPath = config.path {
#if os(macOS)
return absoluteBuildPath.appending(components: "x86_64-apple-macosx", buildConfig)
#else
return absoluteBuildPath.appending(components: "x86_64-unknown-linux", buildConfig)
#endif
} else {
#if os(macOS)
return root.appending(components: ".build", "x86_64-apple-macosx", buildConfig)
#else
return root.appending(components: ".build", "x86_64-unknown-linux", buildConfig)
#endif
}
let buildPath = config.path ?? root.appending(component: ".build")
return buildPath.appending(components: Triple.hostTriple.tripleString, "\(config.configuration)")
}