Skip to content

Commit 7d963e1

Browse files
committed
DarwinCompatibilityTest fixes
- Move DarwinShims.swift into DarwinCompatibilityTests subdir. - Disable more tests that crash on Darwin native. - Use DEPLOYMENT_RUNTIME_OBJC instead of DARWIN_COMPATIBILITY_TESTS to disable a deallocate() that isnt needed for AutoReleasing objects.
1 parent c4aad6e commit 7d963e1

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

DarwinCompatibilityTests.xcodeproj/project.pbxproj

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
B95788861F6FB9470003EB01 /* TestNSNumberBridging.swift in Sources */ = {isa = PBXBuildFile; fileRef = B95788851F6FB9470003EB01 /* TestNSNumberBridging.swift */; };
11-
B9C0F82B1F8EADAF0047CC52 /* DarwinShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C0F8291F8EADAF0047CC52 /* DarwinShims.swift */; };
1211
B9C89ED21F6BF67C00087AF4 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9C89ED11F6BF67C00087AF4 /* XCTest.framework */; };
1312
B9C89F361F6BF89C00087AF4 /* TestScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C89EE61F6BF88F00087AF4 /* TestScanner.swift */; };
1413
B9C89F371F6BF89C00087AF4 /* TestNSValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C89EE71F6BF88F00087AF4 /* TestNSValue.swift */; };
@@ -107,6 +106,8 @@
107106
B9C89FCC1F6DCAEB00087AF4 /* NSKeyedUnarchiver-NotificationTest.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9C89FB71F6DCAEB00087AF4 /* NSKeyedUnarchiver-NotificationTest.plist */; };
108107
B9C89FCD1F6DCAEB00087AF4 /* PropertyList-1.0.dtd in Resources */ = {isa = PBXBuildFile; fileRef = B9C89FB81F6DCAEB00087AF4 /* PropertyList-1.0.dtd */; };
109108
B9C89FCE1F6DCAEB00087AF4 /* Test.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9C89FB91F6DCAEB00087AF4 /* Test.plist */; };
109+
B9F3269F1FC714DD003C3599 /* DarwinShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F3269E1FC714DD003C3599 /* DarwinShims.swift */; };
110+
B9F326A01FC714DD003C3599 /* DarwinShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F3269E1FC714DD003C3599 /* DarwinShims.swift */; };
110111
/* End PBXBuildFile section */
111112

112113
/* Begin PBXCopyFilesBuildPhase section */
@@ -123,9 +124,7 @@
123124

124125
/* Begin PBXFileReference section */
125126
B95788851F6FB9470003EB01 /* TestNSNumberBridging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TestNSNumberBridging.swift; path = TestFoundation/TestNSNumberBridging.swift; sourceTree = "<group>"; };
126-
B9C0F8291F8EADAF0047CC52 /* DarwinShims.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarwinShims.swift; sourceTree = "<group>"; };
127127
B9C89EC11F6BF47D00087AF4 /* DarwinCompatibilityTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DarwinCompatibilityTests; sourceTree = BUILT_PRODUCTS_DIR; };
128-
B9C89ECB1F6BF49800087AF4 /* TestFoundation */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TestFoundation; path = ../TestFoundation; sourceTree = "<group>"; };
129128
B9C89ED11F6BF67C00087AF4 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
130129
B9C89ED71F6BF77E00087AF4 /* DarwinCompatibilityTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DarwinCompatibilityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
131130
B9C89EDB1F6BF77E00087AF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -229,6 +228,7 @@
229228
B9C89FB71F6DCAEB00087AF4 /* NSKeyedUnarchiver-NotificationTest.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "NSKeyedUnarchiver-NotificationTest.plist"; path = "TestFoundation/Resources/NSKeyedUnarchiver-NotificationTest.plist"; sourceTree = "<group>"; };
230229
B9C89FB81F6DCAEB00087AF4 /* PropertyList-1.0.dtd */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "PropertyList-1.0.dtd"; path = "TestFoundation/Resources/PropertyList-1.0.dtd"; sourceTree = "<group>"; };
231230
B9C89FB91F6DCAEB00087AF4 /* Test.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Test.plist; path = TestFoundation/Resources/Test.plist; sourceTree = "<group>"; };
231+
B9F3269E1FC714DD003C3599 /* DarwinShims.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DarwinShims.swift; sourceTree = "<group>"; };
232232
/* End PBXFileReference section */
233233

234234
/* Begin PBXFrameworksBuildPhase section */
@@ -253,7 +253,6 @@
253253
B9C89EB81F6BF47D00087AF4 = {
254254
isa = PBXGroup;
255255
children = (
256-
B9C0F8291F8EADAF0047CC52 /* DarwinShims.swift */,
257256
B95788851F6FB9470003EB01 /* TestNSNumberBridging.swift */,
258257
B9C89FAC1F6DCAE700087AF4 /* Info.plist */,
259258
B9C89FAD1F6DCAE800087AF4 /* NSKeyedUnarchiver-ArrayTest.plist */,
@@ -354,7 +353,6 @@
354353
B9C89EED1F6BF89000087AF4 /* TestXMLParser.swift */,
355354
B9C89F131F6BF89600087AF4 /* xdgTestHelper */,
356355
B9C89F021F6BF89300087AF4 /* XDGTestHelper.swift */,
357-
B9C89EC31F6BF47D00087AF4 /* DarwinCompatibilityTests */,
358356
B9C89ED81F6BF77E00087AF4 /* DarwinCompatibilityTests */,
359357
B9C89EC21F6BF47D00087AF4 /* Products */,
360358
B9C89ED01F6BF67C00087AF4 /* Frameworks */,
@@ -370,14 +368,6 @@
370368
name = Products;
371369
sourceTree = "<group>";
372370
};
373-
B9C89EC31F6BF47D00087AF4 /* DarwinCompatibilityTests */ = {
374-
isa = PBXGroup;
375-
children = (
376-
B9C89ECB1F6BF49800087AF4 /* TestFoundation */,
377-
);
378-
path = DarwinCompatibilityTests;
379-
sourceTree = "<group>";
380-
};
381371
B9C89ED01F6BF67C00087AF4 /* Frameworks */ = {
382372
isa = PBXGroup;
383373
children = (
@@ -389,6 +379,7 @@
389379
B9C89ED81F6BF77E00087AF4 /* DarwinCompatibilityTests */ = {
390380
isa = PBXGroup;
391381
children = (
382+
B9F3269E1FC714DD003C3599 /* DarwinShims.swift */,
392383
B9C89EDF1F6BF79000087AF4 /* TestFoundation */,
393384
B9C89EDB1F6BF77E00087AF4 /* Info.plist */,
394385
);
@@ -444,7 +435,7 @@
444435
TargetAttributes = {
445436
B9C89EC01F6BF47D00087AF4 = {
446437
CreatedOnToolsVersion = 9.0;
447-
LastSwiftMigration = 0900;
438+
LastSwiftMigration = 0910;
448439
ProvisioningStyle = Automatic;
449440
};
450441
B9C89ED61F6BF77E00087AF4 = {
@@ -507,6 +498,7 @@
507498
isa = PBXSourcesBuildPhase;
508499
buildActionMask = 2147483647;
509500
files = (
501+
B9F3269F1FC714DD003C3599 /* DarwinShims.swift in Sources */,
510502
);
511503
runOnlyForDeploymentPostprocessing = 0;
512504
};
@@ -547,7 +539,7 @@
547539
B9C89F511F6BF89C00087AF4 /* TestPropertyListSerialization.swift in Sources */,
548540
B9C89F531F6BF89C00087AF4 /* TestNSArray.swift in Sources */,
549541
B9C89F541F6BF89C00087AF4 /* TestFileHandle.swift in Sources */,
550-
B9C0F82B1F8EADAF0047CC52 /* DarwinShims.swift in Sources */,
542+
B9F326A01FC714DD003C3599 /* DarwinShims.swift in Sources */,
551543
B9C89F551F6BF89C00087AF4 /* TestTimer.swift in Sources */,
552544
B9C89F561F6BF89C00087AF4 /* TestTimeZone.swift in Sources */,
553545
B9C89F571F6BF89C00087AF4 /* TestNSNumber.swift in Sources */,
File renamed without changes.

TestFoundation/TestCodable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,15 @@ class TestCodable : XCTestCase {
561561
]
562562

563563
func test_URLComponents_JSON() {
564+
#if !DARWIN_COMPATIBILITY_TESTS // crashes on native Darwin
564565
for (components) in urlComponentsValues {
565566
do {
566567
try expectRoundTripEqualityThroughJSON(for: components)
567568
} catch let error {
568569
XCTFail("\(error)")
569570
}
570571
}
572+
#endif
571573
}
572574
}
573575

TestFoundation/TestNSData.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,33 +3999,37 @@ extension TestNSData {
39993999
}
40004000
XCTAssertEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
40014001
}
4002-
4002+
40034003
func test_validateMutation_slice_mutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound() {
4004+
#if !DARWIN_COMPATIBILITY_TESTS // Crashes on native Darwin
40044005
var base = Data(referencing: NSData(bytes: "hello world", length: 11))
40054006
base.append(contentsOf: [1, 2, 3, 4, 5, 6])
40064007
var data = base[4..<6]
40074008
data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
40084009
ptr.advanced(by: 1).pointee = 0xFF
40094010
}
40104011
XCTAssertEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
4012+
#endif
40114013
}
4012-
4014+
40134015
func test_validateMutation_slice_customBacking_withUnsafeMutableBytes_lengthLessThanLowerBound() {
40144016
var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<6]
40154017
data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
40164018
ptr.advanced(by: 1).pointee = 0xFF
40174019
}
40184020
XCTAssertEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
40194021
}
4020-
4022+
40214023
func test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound() {
4024+
#if !DARWIN_COMPATIBILITY_TESTS // Crashes on native Darwin
40224025
var base = Data(referencing: AllOnesData(length: 1))
40234026
base.count = 10
40244027
var data = base[4..<6]
40254028
data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
40264029
ptr.advanced(by: 1).pointee = 0xFF
40274030
}
40284031
XCTAssertEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
4032+
#endif
40294033
}
40304034
}
40314035

TestFoundation/TestNSKeyedArchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class TestNSKeyedArchiver : XCTestCase {
286286
let s1 = String(cString: charPtr)
287287
let s2 = String(cString: expectedCharPtr!)
288288

289-
#if !DARWIN_COMPATIBILITY_TESTS
289+
#if !DEPLOYMENT_RUNTIME_OBJC
290290
// On Darwin decoded strings would belong to the autorelease pool, but as we don't have
291291
// one in SwiftFoundation let's explicitly deallocate it here.
292292
expectedCharPtr!.deallocate()

0 commit comments

Comments
 (0)