Skip to content

Extend binary target tests to multiple arches #2831

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
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
26 changes: 17 additions & 9 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ final class BuildPlanTests: XCTestCase {
])
}

func testBinaryTargets() throws {
func testBinaryTargets(platform: String, arch: String, destinationTriple: Triple) throws {
let fs = InMemoryFileSystem(emptyFiles:
"/Pkg/Sources/exe/main.swift",
"/Pkg/Sources/Library/Library.swift",
Expand All @@ -2236,15 +2236,15 @@ final class BuildPlanTests: XCTestCase {
<array>
<dict>
<key>LibraryIdentifier</key>
<string>macos-x86_64</string>
<string>\(platform)-\(arch)</string>
<key>LibraryPath</key>
<string>Framework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>\(arch)</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
<string>\(platform)</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand All @@ -2267,17 +2267,17 @@ final class BuildPlanTests: XCTestCase {
<array>
<dict>
<key>LibraryIdentifier</key>
<string>macos-x86_64</string>
<string>\(platform)-\(arch)</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryPath</key>
<string>libStaticLibrary.a</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>\(arch)</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
<string>\(platform)</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down Expand Up @@ -2316,7 +2316,7 @@ final class BuildPlanTests: XCTestCase {
XCTAssertNoDiagnostics(diagnostics)

let result = BuildPlanResult(plan: try BuildPlan(
buildParameters: mockBuildParameters(destinationTriple: .macOS),
buildParameters: mockBuildParameters(destinationTriple: destinationTriple),
graph: graph,
diagnostics: diagnostics,
fileSystem: fs
Expand Down Expand Up @@ -2344,7 +2344,7 @@ final class BuildPlanTests: XCTestCase {

let clibraryBasicArguments = try result.target(for: "CLibrary").clangTarget().basicArguments()
XCTAssertMatch(clibraryBasicArguments, [.anySequence, "-F", "/path/to/build/debug", .anySequence])
XCTAssertMatch(clibraryBasicArguments, [.anySequence, "-I", "/Pkg/StaticLibrary.xcframework/macos-x86_64/Headers", .anySequence])
XCTAssertMatch(clibraryBasicArguments, [.anySequence, "-I", "/Pkg/StaticLibrary.xcframework/\(platform)-\(arch)/Headers", .anySequence])

let clibraryLinkArguments = try result.buildProduct(for: "CLibrary").linkArguments()
XCTAssertMatch(clibraryLinkArguments, [.anySequence, "-F", "/path/to/build/debug", .anySequence])
Expand All @@ -2358,6 +2358,14 @@ final class BuildPlanTests: XCTestCase {
XCTAssertMatch(dynamicLibraryPathExtension, "dylib")
}

func testBinaryTargets() throws {
try testBinaryTargets(platform: "macos", arch: "x86_64", destinationTriple: .macOS)
let arm64Triple = try Triple("arm64-apple-macosx")
try testBinaryTargets(platform: "macos", arch: "arm64", destinationTriple: arm64Triple)
let arm64eTriple = try Triple("arm64e-apple-macosx")
try testBinaryTargets(platform: "macos", arch: "arm64e", destinationTriple: arm64eTriple)
}

func testAddressSanitizer() throws {
try sanitizerTest(.address, expectedName: "address")
}
Expand Down