Skip to content

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

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
Apr 30, 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)
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)")
}