Skip to content
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

Update swift-test/main.swift to handle Apple Silicon hosts #110

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 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
22 changes: 19 additions & 3 deletions SwiftPMTests/swift-test/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ class importTest: XCTestCase {
// Device model should now return the appropriate hardware model on macOS.
XCTAssertNotEqual(GULAppEnvironmentUtil.deviceModel(), "x86_64")
#else
// Device model should show up as x86_64 for iOS, tvOS, and watchOS
// simulators.
XCTAssertEqual(GULAppEnvironmentUtil.deviceModel(), "x86_64")
// Device model should show up as the host architecture (x86_64 or arm64) for iOS, tvOS,
// watchOS, and visionOS simulators.
XCTAssertEqual(GULAppEnvironmentUtil.deviceModel(), buildArchitecture())
#endif

print("System version? Answer: \(GULAppEnvironmentUtil.systemVersion())")
}

func buildArchitecture() -> String {
#if arch(arm)
return "arm"
#elseif arch(arm64)
return "arm64"
#elseif arch(x86_64)
return "x86_64"
#else
throw TestError(errorDescription: "Unexpected build architecture.")
#endif
}

struct TestError: Error {
var errorDescription: String?
}
}