From 162a80c53cbbb2f12af784859070d1d947aa67cd Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Sun, 20 Aug 2023 22:43:48 -0400 Subject: [PATCH] Preserve env in tripleString(forPlatformVersion:) --- Sources/Basics/Triple+Basics.swift | 6 ++---- Tests/BasicsTests/TripleTests.swift | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/Basics/Triple+Basics.swift b/Sources/Basics/Triple+Basics.swift index 439c980fc1a..7da68ca29ac 100644 --- a/Sources/Basics/Triple+Basics.swift +++ b/Sources/Basics/Triple+Basics.swift @@ -64,13 +64,11 @@ extension Triple { /// This is currently meant for Apple platforms only. public func tripleString(forPlatformVersion version: String) -> String { precondition(isDarwin()) - // This function did not handle triples with a specific environments and - // object formats previously to using SwiftDriver.Triple and still does - // not. return """ \(self.archName)-\ \(self.vendorName)-\ - \(self.osNameUnversioned)\(version) + \(self.osNameUnversioned)\(version)\ + \(self.environmentName.isEmpty ? "" : "-\(self.environmentName)") """ } diff --git a/Tests/BasicsTests/TripleTests.swift b/Tests/BasicsTests/TripleTests.swift index bc4ebbf800a..aa392c0c5ee 100644 --- a/Tests/BasicsTests/TripleTests.swift +++ b/Tests/BasicsTests/TripleTests.swift @@ -122,6 +122,12 @@ final class TripleTests: XCTestCase { XCTAssertTriple("mips-apple-darwin19", forPlatformVersion: "", is: "mips-apple-darwin") XCTAssertTriple("mips-apple-darwin19", forPlatformVersion: "22", is: "mips-apple-darwin22") + + XCTAssertTriple("arm64-apple-ios-simulator", forPlatformVersion: "", is: "arm64-apple-ios-simulator") + XCTAssertTriple("arm64-apple-ios-simulator", forPlatformVersion: "13.0", is: "arm64-apple-ios13.0-simulator") + + XCTAssertTriple("arm64-apple-ios12-simulator", forPlatformVersion: "", is: "arm64-apple-ios-simulator") + XCTAssertTriple("arm64-apple-ios12-simulator", forPlatformVersion: "13.0", is: "arm64-apple-ios13.0-simulator") } func testKnownTripleParsing() {