@@ -19,6 +19,7 @@ import XCTest
19
19
private let bundleRootPath = try ! AbsolutePath ( validating: " /tmp/cross-toolchain " )
20
20
private let toolchainBinDir = bundleRootPath. appending ( . init( " swift.xctoolchain/usr/bin " ) )
21
21
private let sdkRootDir = bundleRootPath. appending ( . init( " ubuntu-jammy.sdk " ) )
22
+ private let hostTriple = " arm64-apple-darwin22.1.0 "
22
23
private let destinationTriple = " x86_64-unknown-linux-gnu "
23
24
private let extraFlags = BuildFlags (
24
25
cCompilerFlags: [ " -fintegrated-as " ] ,
@@ -40,11 +41,29 @@ private let destinationV1JSON =
40
41
}
41
42
"""#
42
43
43
- class DestinationTests : XCTestCase {
44
+ private let destinationV2JSON =
45
+ #"""
46
+ {
47
+ "version": 2,
48
+ "sdkRootDir": " \#( sdkRootDir) ",
49
+ "toolchainBinDir": " \#( toolchainBinDir) ",
50
+ "hostTriple": " \#( hostTriple) ",
51
+ "destinationTriple": " \#( destinationTriple) ",
52
+ "extraCCFlags": \#( extraFlags. cCompilerFlags) ,
53
+ "extraSwiftCFlags": \#( extraFlags. swiftCompilerFlags) ,
54
+ "extraCXXFlags": \#( extraFlags. cxxCompilerFlags) ,
55
+ "extraLinkerFlags": \#( extraFlags. linkerFlags)
56
+ }
57
+ """#
58
+
59
+ final class DestinationTests : XCTestCase {
44
60
func testDestinationCodable( ) throws {
45
- let fs = InMemoryFileSystem ( files: [ " /sdk/destination.json " : ByteString ( encodingAsUTF8: destinationV1JSON) ] )
61
+ let fs = InMemoryFileSystem ( files: [
62
+ " /sdk/destinationV1.json " : ByteString ( encodingAsUTF8: destinationV1JSON) ,
63
+ " /sdk/destinationV2.json " : ByteString ( encodingAsUTF8: destinationV2JSON) ,
64
+ ] )
46
65
47
- let destinationV1 = try Destination ( fromFile: AbsolutePath ( validating: " /sdk/destination .json " ) , fileSystem: fs)
66
+ let destinationV1 = try Destination ( fromFile: AbsolutePath ( validating: " /sdk/destinationV1 .json " ) , fileSystem: fs)
48
67
49
68
var flagsWithoutLinkerFlags = extraFlags
50
69
flagsWithoutLinkerFlags. linkerFlags = [ ]
@@ -58,5 +77,18 @@ class DestinationTests: XCTestCase {
58
77
extraFlags: flagsWithoutLinkerFlags
59
78
)
60
79
)
80
+
81
+ let destinationV2 = try Destination ( fromFile: AbsolutePath ( validating: " /sdk/destinationV2.json " ) , fileSystem: fs)
82
+
83
+ XCTAssertEqual (
84
+ destinationV2,
85
+ Destination (
86
+ hostTriple: try Triple ( hostTriple) ,
87
+ destinationTriple: try Triple ( destinationTriple) ,
88
+ sdkRootDir: sdkRootDir,
89
+ toolchainBinDir: toolchainBinDir,
90
+ extraFlags: extraFlags
91
+ )
92
+ )
61
93
}
62
94
}
0 commit comments