Skip to content

Commit 2fbe384

Browse files
committed
DarwinCompatibilityTest: Update working test list and shims
- DarwinShims: Remove the extensions to FileHandle and Scanner as the missing functions are in the latest macOS 10.15 release. - TestsToSkip: Update the list of tests to skip when running DarwinCompatibilityTests/xcode-build.sh to be more granular and also remove tests that now pass. - FileHandle.readInBackgroundAndNotify(): If the read fails the userInfo NSFileHandleNotificationDataItem entry should be an empty Data() not nil.
1 parent ad50bdf commit 2fbe384

File tree

4 files changed

+45
-72
lines changed

4 files changed

+45
-72
lines changed

DarwinCompatibilityTests/DarwinShims.swift

-34
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ extension Thread {
4545
}
4646
}
4747

48-
extension Scanner {
49-
public func scanString(_ searchString: String) -> String? {
50-
var result: NSString? = nil
51-
if scanString(searchString, into: &result), let str = result {
52-
return str as String
53-
}
54-
return nil
55-
}
56-
}
57-
5848
extension JSONSerialization {
5949
class func writeJSONObject(_ obj: Any, toStream stream: OutputStream, options opt: WritingOptions) throws -> Int {
6050
var error: NSError?
@@ -83,27 +73,3 @@ extension NSCharacterSet {
8373
return self as CharacterSet
8474
}
8575
}
86-
87-
88-
extension FileHandle {
89-
public func offset() throws -> UInt64 {
90-
return self.offsetInFile
91-
}
92-
93-
public func read(upToCount count: Int) throws -> Data? {
94-
guard count > 0 else { return nil }
95-
let data = readData(ofLength: count)
96-
if data.count == 0 { return nil }
97-
return data
98-
}
99-
100-
public func readToEnd() throws -> Data? {
101-
try read(upToCount: Int.max)
102-
}
103-
104-
public func write<T: DataProtocol>(contentsOf data: T) throws {
105-
if let d = data as? Data {
106-
self.write(d)
107-
}
108-
}
109-
}
+43-37
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,82 @@
1+
TestBridging
12
TestByteCountFormatter
23
TestCachedURLResponse/test_equalCheckingData
34
TestCachedURLResponse/test_equalCheckingResponse
45
TestCachedURLResponse/test_equalCheckingStoragePolicy
56
TestCachedURLResponse/test_hash
6-
TestCodable
7-
TestDateComponents
8-
TestDateFormatter
9-
TestDateIntervalFormatter
10-
TestDecimal
11-
TestFileHandle/testReadToEnd
12-
TestFileHandle/testReadUpToCount
13-
TestFileHandle/testWritingWithBuffer
14-
TestFileHandle/testWritingWithMultiregionData
15-
TestFileHandle/test_readToEndOfFileAndNotify_readError
7+
TestDataURLProtocol/test_invalidURIs
8+
TestDateFormatter/test_dateStyleMedium
9+
TestDateFormatter/test_expectedTimeZone
10+
TestDateIntervalFormatter/testDecodingFixtures
11+
TestDecimal/test_NSDecimalNumberValues
12+
TestDecimal/test_multiplyingByPowerOf10
1613
TestFileManager
1714
TestHTTPCookie
18-
TestHTTPCookieStorage
19-
TestHTTPURLResponse
20-
TestISO8601DateFormatter
21-
TestIndexPath
22-
TestIndexSet
23-
TestJSONEncoder
15+
TestHTTPCookieStorage/test_removeCookies
16+
TestHTTPURLResponse/test_suggestedFilename_4
17+
TestISO8601DateFormatter/test_loadingFixtures
18+
TestIndexPath/testLoadedValuesMatch
19+
TestIndexSet/testLoadedValuesMatch
2420
TestJSONSerialization
2521
TestLengthFormatter
26-
TestMeasurement
22+
TestMeasurement/testLoadedValuesMatch
2723
TestNSArray
28-
TestNSAttributedString
24+
TestNSAttributedString/test_unarchivingFixtures
2925
TestNSCache
30-
TestNSData
31-
TestNSDateComponents
32-
TestNSDictionary
26+
TestNSData/test_description
27+
TestNSData/test_edgeDebugDescription
28+
TestNSData/test_edgeNoCopyDescription
29+
TestNSData/test_emptyDescription
30+
TestNSData/test_longDebugDescription
31+
TestNSData/test_longDescription
32+
TestNSDateComponents/test_hash
33+
TestNSDictionary/test_copying
34+
TestNSDictionary/test_mutableCopying
3335
TestNSGeometry
3436
TestNSKeyedArchiver
3537
TestNSMutableAttributedString
3638
TestNSNumber
37-
TestNSOrderedSet
39+
TestNSNumberBridging/testNSNumberBridgeFromDouble
40+
TestNSNumberBridging/testNSNumberBridgeFromFloat
41+
TestNSOrderedSet/test_enumerationUsingBlock
42+
TestNSOrderedSet/test_loadedValuesMatch
3843
TestNSRegularExpression
3944
TestNSSet
40-
TestNSSortDescriptor
41-
TestNSString
42-
TestNSTextCheckingResult
43-
TestNSURLRequest
45+
TestNSString/test_FromContentsOfURLUsedEncodingUTF16BE
46+
TestNSString/test_FromContentsOfURLUsedEncodingUTF16LE
47+
TestNSString/test_FromContentsOfURLUsedEncodingUTF32BE
48+
TestNSString/test_FromContentsOfURLUsedEncodingUTF32LE
49+
TestNSTextCheckingResult/test_loadedVauesMatch
50+
TestNSURLRequest/test_hash
4451
TestNotificationQueue
45-
TestNumberFormatter
52+
TestNumberFormatter/test_settingFormat
4653
TestObjCRuntime
47-
TestProcess
48-
TestProcessInfo
49-
TestRunLoop
54+
TestProcess/test_currentDirectory
55+
TestProcess/test_plutil
56+
TestProcessInfo/test_globallyUniqueString
5057
TestScanner/testHexFloatingPoint
51-
TestScanner/testScanString
5258
TestSocketPort/testSendingOneMessageRemoteToLocal
53-
TestTimeZone
54-
TestURL
59+
TestURLCache/testNoMemoryUsageIfDisabled
5560
TestURLCache/testRemovingAll
5661
TestURLCache/testRemovingOne
5762
TestURLCache/testRemovingSince
5863
TestURLCache/testShrinkingDiskCapacityEvictsItems
5964
TestURLCache/testShrinkingMemoryCapacityEvictsItems
6065
TestURLCache/testStoragePolicy
6166
TestURLCache/testStoringTwiceOnlyHasOneEntry
62-
TestURLComponents
67+
TestURLCredentialStorage/test_storageStartsEmpty
6368
TestURLCredentialStorage/test_storageWillSendNotificationWhenAddingDifferentDefaultCredential
6469
TestURLCredentialStorage/test_storageWillSendNotificationWhenAddingExistingCredentialToDifferentSpace
6570
TestURLCredentialStorage/test_storageWillSendNotificationWhenAddingNewCredential
6671
TestURLCredentialStorage/test_storageWillSendNotificationWhenAddingNewDefaultCredential
6772
TestURLCredentialStorage/test_storageWillSendNotificationWhenRemovingDefaultNotification
6873
TestURLCredentialStorage/test_storageWillSendNotificationWhenRemovingExistingCredential
69-
TestURLProtocol
70-
TestURLRequest
74+
TestURLProtocol/test_customProtocolResponseWithDelegate
75+
TestURLProtocol/test_customProtocolSetDataInResponseWithDelegate
7176
TestURLResponse
77+
TestURLSession
7278
TestURLSessionFTP
7379
TestUnit
74-
TestUserDefaults
80+
TestUserDefaults/test_setValue_NSURL
7581
TestXMLDocument
7682
TestXMLParser

Sources/Foundation/FileHandle.swift

+1
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ extension FileHandle {
847847
if error == 0 {
848848
userInfo[NSFileHandleNotificationDataItem] = Data(data)
849849
} else {
850+
userInfo[NSFileHandleNotificationDataItem] = Data()
850851
#if os(Windows)
851852
// On Windows, reading from a directory results in an
852853
// ERROR_ACCESS_DENIED. If we get ERROR_ACCESS_DENIED

Tests/Foundation/Tests/TestFileHandle.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class TestFileHandle : XCTestCase {
513513
return true
514514
}
515515

516-
XCTAssertNil(notification.userInfo?[NSFileHandleNotificationDataItem])
516+
XCTAssertEqual(notification.userInfo?[NSFileHandleNotificationDataItem] as? Data, Data())
517517
#if os(Windows)
518518
XCTAssertEqual(error, NSNumber(value: ERROR_DIRECTORY_NOT_SUPPORTED))
519519
#else

0 commit comments

Comments
 (0)