Skip to content

Commit 65c49c9

Browse files
authored
Merge pull request #148 from Automattic/xcode-16.4
Update Xcode version to 16.4 & Fix Unit Tests
2 parents 7f16009 + a303f4e commit 65c49c9

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ agents:
55
queue: mac
66

77
env:
8-
IMAGE_ID: xcode-16.1-v4
8+
IMAGE_ID: xcode-16.4
99

1010
# Nodes with values to reuse in the pipeline.
1111
common_params:

Tests/libhostmgrTests/TestHelpers.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ extension S3Object {
1818
}
1919
}
2020

21-
extension XCTest {
22-
func XCTAssert(_ data: Data, hasHash hash: String, file: StaticString = #file, line: UInt = #line) {
23-
var hasher = SHA256()
24-
hasher.update(data: data)
25-
XCTAssertEqual(Data(hasher.finalize()).base64EncodedString(), hash, file: file, line: line)
26-
}
27-
}
28-
2921
func getPathForEnvFile(named key: String) -> URL {
3022
Bundle.module.url(forResource: key, withExtension: "env")!
3123
}

Tests/libhostmgrTests/VM/VMConfigFileTests.swift

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,36 @@ final class VMConfigFileTests: XCTestCase {
2727
}
2828

2929
func testThatHardwareModelIsParsedCorrectly() throws {
30-
XCTAssert(
31-
try configFileSample1.hardwareModel.dataRepresentation,
32-
hasHash: "3aTbdKrJ+27C8JaCzSmHNr32t5IbeuA5VjC48XCcGu8="
33-
)
30+
let dataRep = try configFileSample1.hardwareModel.dataRepresentation
31+
// The `dataRepresentation` is supposed to be an opaque value / implementation detail,
32+
// but that's the only property we have access to and we can thus use for testing correct parsing.
33+
//
34+
// This `dataRepresentation` happens to be a binary plist representation of a NSDictionary.
35+
// We can't just compare the `dataRepresentation` directly with a fixed value though, because different
36+
// versions of macOS might serialize the exact same NSDictionary as a slightly different NSData representation.
37+
// Besides, future macOS versions might add additional keys in that internal representation of those objects.
38+
//
39+
// So the best we can do is check that the `dataRepresentation` is not nil and check some keys in that dict.
40+
// This is a bit fragile but at least it's more resilient than comparing the `dataRepresentation` directly.
41+
let dictRep = try XCTUnwrap(PropertyListSerialization.propertyList(from: dataRep, format: nil) as? NSDictionary)
42+
XCTAssertEqual(dictRep["MinimumSupportedOS"] as? NSArray, [13, 0, 0])
43+
XCTAssertEqual(dictRep["PlatformVersion"] as? NSNumber, 2)
3444
}
3545

3646
func testThatMachineIdentifierIsParsedCorrectly() throws {
37-
XCTAssert(
38-
try configFileSample1.machineIdentifier.dataRepresentation,
39-
hasHash: "0DXW7UIFta6W86ZZd24QUy4Gx3EX1+r9i+yYk7xHi0s="
40-
)
47+
let dataRep = try configFileSample1.machineIdentifier.dataRepresentation
48+
// The `dataRepresentation` is supposed to be an opaque value / implementation detail,
49+
// but that's the only property we have access to and we can thus use for testing correct parsing.
50+
//
51+
// This `dataRepresentation` happens to be a binary plist representation of a NSDictionary.
52+
// We can't just compare the `dataRepresentation` directly with a fixed value though, because different
53+
// versions of macOS might serialize the exact same NSDictionary as a slightly different NSData representation.
54+
// Besides, future macOS versions might add additional keys in that internal representation of those objects.
55+
//
56+
// So the best we can do is check that the `dataRepresentation` is not nil and check some keys in that dict.
57+
// This is a bit fragile but at least it's more resilient than comparing the `dataRepresentation` directly.
58+
let dictRep = try XCTUnwrap(PropertyListSerialization.propertyList(from: dataRep, format: nil) as? NSDictionary)
59+
XCTAssertNotNil(dictRep["ECID"])
4160
}
4261

4362
func testThatMacAddressIsParsedCorrectly() throws {

0 commit comments

Comments
 (0)