Skip to content

Commit 31c93c7

Browse files
authored
Fix Package test failures for Linux
* Fix TestURL linux failures * Fix FileManagerTests - delete failing tests covered by swift-foundation, disable platform specific and XFail tests * Update availability / skipping of TestURLSession tests * Update TestNSString test availability * Delete incorrect NSString test * Fix NSOrderedSet tests * Fix NSError tests * Fix some NSData tests * Fix TestCocoaError issues * Fix TestOperationQueue test availability * Fix TestNSDateComponents failures * Fix TestBundle failures * Fix TestProcess failures * Fix TestDateFormatter failures * Fix TestHTTPCookieStorage failures * Remove all constant allTests declarations * Fix TestNSData test failures * Remove remainder of allTests conditional logic
1 parent cd9a1a2 commit 31c93c7

File tree

103 files changed

+179
-3021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+179
-3021
lines changed

Sources/Foundation/NSError.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public let NSDebugDescriptionErrorKey = "NSDebugDescription"
4545
// Other standard keys in userInfo, for various error codes
4646
public let NSStringEncodingErrorKey: String = "NSStringEncodingErrorKey"
4747
public let NSURLErrorKey: String = "NSURL"
48-
public let NSFilePathErrorKey: String = "NSFilePathErrorKey"
48+
public let NSFilePathErrorKey: String = "NSFilePath"
4949

5050
open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
5151
typealias CFType = CFError
@@ -610,7 +610,7 @@ extension CocoaError {
610610
public static func error(_ code: CocoaError.Code, userInfo: [String : AnyHashable]? = nil, url: Foundation.URL? = nil) -> Error {
611611
var info: [String : AnyHashable] = userInfo ?? [:]
612612
if let url = url {
613-
info["NSURLErrorKey"] = url
613+
info[NSURLErrorKey] = url
614614
}
615615
return CocoaError(code, userInfo: info)
616616
}

Sources/Foundation/NSOrderedSet.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ open class NSOrderedSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
277277
}
278278

279279
open func enumerateObjects(at s: IndexSet, options opts: NSEnumerationOptions = [], using block: (Any, Int, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
280-
_orderedStorage.enumerateObjects(options: opts, using: block)
280+
_orderedStorage.enumerateObjects(at: s, options: opts, using: block)
281281
}
282282

283283
open func index(ofObjectPassingTest predicate: (Any, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {

Sources/xdgTestHelper/main.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class XDGCheck {
4949
storage.setCookie(simpleCookie)
5050
let fm = FileManager.default
5151

52-
guard let bundleName = Bundle.main.infoDictionary?["CFBundleName"] as? String else {
53-
exit(HelperCheckStatus.fail.rawValue)
54-
}
52+
let bundleName = Bundle.main.bundlePath.split(separator: "/").last!.prefix(while: { $0 != "." })
5553
let destPath = xdg_data_home + "/" + bundleName + "/.cookies.shared"
5654
var isDir: ObjCBool = false
5755
let exists = fm.fileExists(atPath: destPath, isDirectory: &isDir)

Tests/Foundation/TestAffineTransform.swift

-24
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,6 @@ public struct Vector {
2727

2828
class TestAffineTransform: XCTestCase {
2929
private let accuracyThreshold: CGFloat = 0.001
30-
31-
static var allTests: [(String, (TestAffineTransform) -> () throws -> Void)] {
32-
return [
33-
("testConstruction", testConstruction),
34-
("testBridging", testBridging),
35-
("testEqualityHashing", testEqualityHashing),
36-
("testVectorTransformations", testVectorTransformations),
37-
("testIdentityConstruction", testIdentityConstruction),
38-
("testIdentity", testIdentity),
39-
("testTranslationConstruction", testTranslationConstruction),
40-
("testTranslation", testTranslation),
41-
("testScalingConstruction", testScalingConstruction),
42-
("testScaling", testScaling),
43-
("testRotationConstruction", testRotationConstruction),
44-
("testRotation", testRotation),
45-
("testTranslationScaling", testTranslationScaling),
46-
("testTranslationRotation", testTranslationRotation),
47-
("testScalingRotation", testScalingRotation),
48-
("testInversion", testInversion),
49-
("testPrependTransform", testPrependTransform),
50-
("testAppendTransform", testAppendTransform),
51-
("testNSCoding", testNSCoding),
52-
]
53-
}
5430
}
5531

5632
// MARK: - Helper

Tests/Foundation/TestBridging.swift

-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ struct StructWithDescriptionAndDebugDescription:
2323
}
2424

2525
class TestBridging : XCTestCase {
26-
static var allTests: [(String, (TestBridging) -> () throws -> Void)] {
27-
return [
28-
("testBridgedDescription", testBridgedDescription),
29-
("testDynamicCast", testDynamicCast),
30-
("testConstantsImmortal", testConstantsImmortal),
31-
]
32-
}
33-
3426
func testBridgedDescription() throws {
3527
#if canImport(Foundation) && canImport(SwiftFoundation)
3628
/*

Tests/Foundation/TestBundle.swift

+7-33
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#endif
1616
#endif
1717

18-
internal func testBundle() -> Bundle {
18+
internal func testBundle(executable: Bool = false) -> Bundle {
1919
#if DARWIN_COMPATIBILITY_TESTS
2020
for bundle in Bundle.allBundles {
2121
if let bundleId = bundle.bundleIdentifier, bundleId == "org.swift.DarwinCompatibilityTests", bundle.resourcePath != nil {
@@ -24,7 +24,7 @@ internal func testBundle() -> Bundle {
2424
}
2525
fatalError("Cant find test bundle")
2626
#else
27-
return Bundle.module
27+
return executable ? Bundle.main : Bundle.module
2828
#endif
2929
}
3030

@@ -474,13 +474,13 @@ class TestBundle : XCTestCase {
474474
}
475475

476476
func test_bundleLoad() {
477-
let bundle = testBundle()
477+
let bundle = testBundle(executable: true)
478478
let _ = bundle.load()
479479
XCTAssertTrue(bundle.isLoaded)
480480
}
481481

482482
func test_bundleLoadWithError() {
483-
let bundleValid = testBundle()
483+
let bundleValid = testBundle(executable: true)
484484

485485
// Test valid load using loadAndReturnError
486486
do {
@@ -503,7 +503,7 @@ class TestBundle : XCTestCase {
503503
}
504504

505505
func test_bundlePreflight() {
506-
XCTAssertNoThrow(try testBundle().preflight())
506+
XCTAssertNoThrow(try testBundle(executable: true).preflight())
507507

508508
try! _withEachPlaygroundLayout { (playground) in
509509
let bundle = Bundle(path: playground.bundlePath)!
@@ -514,7 +514,7 @@ class TestBundle : XCTestCase {
514514
}
515515

516516
func test_bundleFindExecutable() {
517-
XCTAssertNotNil(testBundle().executableURL)
517+
XCTAssertNotNil(testBundle(executable: true).executableURL)
518518

519519
_withEachPlaygroundLayout { (playground) in
520520
let bundle = Bundle(path: playground.bundlePath)!
@@ -564,32 +564,6 @@ class TestBundle : XCTestCase {
564564
#endif
565565

566566
func test_bundleForClass() {
567-
XCTAssertEqual(testBundle(), Bundle(for: type(of: self)))
568-
}
569-
570-
static var allTests: [(String, (TestBundle) -> () throws -> Void)] {
571-
var tests: [(String, (TestBundle) -> () throws -> Void)] = [
572-
("test_paths", test_paths),
573-
("test_resources", test_resources),
574-
("test_infoPlist", test_infoPlist),
575-
("test_localizations", test_localizations),
576-
("test_URLsForResourcesWithExtension", test_URLsForResourcesWithExtension),
577-
("test_bundleLoad", test_bundleLoad),
578-
("test_bundleLoadWithError", test_bundleLoadWithError),
579-
("test_bundleWithInvalidPath", test_bundleWithInvalidPath),
580-
("test_bundlePreflight", testExpectedToFailOnWindows(test_bundlePreflight, "Preflight checks aren't supported for DLLs")),
581-
("test_bundleFindExecutable", test_bundleFindExecutable),
582-
("test_bundleFindAuxiliaryExecutables", test_bundleFindAuxiliaryExecutables),
583-
("test_bundleForClass", testExpectedToFailOnWindows(test_bundleForClass, "Functionality not yet implemented on Windows. SR-XXXX")),
584-
]
585-
586-
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
587-
tests.append(contentsOf: [
588-
("test_mainBundleExecutableURL", test_mainBundleExecutableURL),
589-
("test_bundleReverseBundleLookup", test_bundleReverseBundleLookup),
590-
])
591-
#endif
592-
593-
return tests
567+
XCTAssertEqual(testBundle(executable: true), Bundle(for: type(of: self)))
594568
}
595569
}

Tests/Foundation/TestByteCountFormatter.swift

-27
Original file line numberDiff line numberDiff line change
@@ -455,31 +455,4 @@ class TestByteCountFormatter : XCTestCase {
455455
}
456456
}
457457
}
458-
459-
static var allTests: [(String, (TestByteCountFormatter) -> () throws -> Void)] {
460-
return [
461-
("test_DefaultValues", test_DefaultValues),
462-
("test_zeroBytes", test_zeroBytes),
463-
("test_oneByte", test_oneByte),
464-
("test_allowedUnitsKBGB", test_allowedUnitsKBGB),
465-
("test_allowedUnitsMBGB", test_allowedUnitsMBGB),
466-
("test_adaptiveFalseAllowedUnitsKBMBGB", test_adaptiveFalseAllowedUnitsKBMBGB),
467-
("test_allowedUnitsKBMBGB", test_allowedUnitsKBMBGB),
468-
("test_allowedUnitsBytesGB", test_allowedUnitsBytesGB),
469-
("test_allowedUnitsGB", test_allowedUnitsGB),
470-
("test_adaptiveFalseAllowedUnitsGB", test_adaptiveFalseAllowedUnitsGB),
471-
("test_numberOnly", test_numberOnly),
472-
("test_unitOnly", test_unitOnly),
473-
("test_isAdaptiveFalse", test_isAdaptiveFalse),
474-
("test_isAdaptiveTrue", test_isAdaptiveTrue),
475-
("test_zeroPadsFractionDigitsTrue", test_zeroPadsFractionDigitsTrue),
476-
("test_isAdaptiveFalseZeroPadsFractionDigitsTrue", test_isAdaptiveFalseZeroPadsFractionDigitsTrue),
477-
("test_countStyleDecimal", test_countStyleDecimal),
478-
("test_countStyleBinary", test_countStyleBinary),
479-
("test_largeByteValues", test_largeByteValues),
480-
("test_negativeByteValues", test_negativeByteValues),
481-
("test_unarchivingFixtures", test_unarchivingFixtures),
482-
]
483-
}
484-
485458
}

Tests/Foundation/TestCachedURLResponse.swift

-15
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,4 @@ class TestCachedURLResponse : XCTestCase {
188188
XCTAssertNotEqual(cachedResponse1.hash, cachedResponse3.hash)
189189
XCTAssertNotEqual(cachedResponse2.hash, cachedResponse3.hash)
190190
}
191-
192-
static var allTests: [(String, (TestCachedURLResponse) -> () throws -> Void)] {
193-
return [
194-
("test_copy", test_copy),
195-
("test_initDefaultUserInfoAndStoragePolicy", test_initDefaultUserInfoAndStoragePolicy),
196-
("test_initDefaultUserInfo", test_initDefaultUserInfo),
197-
("test_initWithoutDefaults", test_initWithoutDefaults),
198-
("test_equalWithTheSameInstance", test_equalWithTheSameInstance),
199-
("test_equalWithUnrelatedObject", test_equalWithUnrelatedObject),
200-
("test_equalCheckingResponse", test_equalCheckingResponse),
201-
("test_equalCheckingData", test_equalCheckingData),
202-
("test_equalCheckingStoragePolicy", test_equalCheckingStoragePolicy),
203-
("test_hash", test_hash),
204-
]
205-
}
206191
}

Tests/Foundation/TestCalendar.swift

-23
Original file line numberDiff line numberDiff line change
@@ -287,27 +287,4 @@ class TestCalendar: XCTestCase {
287287
XCTAssertNil(next)
288288
}
289289
}
290-
291-
static var allTests: [(String, (TestCalendar) -> () throws -> Void)] {
292-
return [
293-
("test_allCalendars", test_allCalendars),
294-
("test_gettingDatesOnGregorianCalendar", test_gettingDatesOnGregorianCalendar ),
295-
("test_gettingDatesOnHebrewCalendar", test_gettingDatesOnHebrewCalendar ),
296-
("test_gettingDatesOnChineseCalendar", test_gettingDatesOnChineseCalendar),
297-
("test_gettingDatesOnISO8601Calendar", test_gettingDatesOnISO8601Calendar),
298-
("test_gettingDatesOnPersianCalendar", test_gettingDatesOnPersianCalendar),
299-
("test_gettingDatesOnJapaneseCalendar", test_gettingDatesOnJapaneseCalendar),
300-
("test_copy",test_copy),
301-
("test_addingDates", test_addingDates),
302-
("test_datesNotOnWeekend", test_datesNotOnWeekend),
303-
("test_datesOnWeekend", test_datesOnWeekend),
304-
("test_customMirror", test_customMirror),
305-
("test_ampmSymbols", test_ampmSymbols),
306-
("test_currentCalendarRRstability", test_currentCalendarRRstability),
307-
("test_hashing", test_hashing),
308-
("test_dateFromDoesntMutate", test_dateFromDoesntMutate),
309-
("test_sr10638", test_sr10638),
310-
("test_nextDate", test_nextDate),
311-
]
312-
}
313290
}

Tests/Foundation/TestCharacterSet.swift

-30
Original file line numberDiff line numberDiff line change
@@ -370,34 +370,4 @@ class TestCharacterSet : XCTestCase {
370370
try fixture.assertValueRoundtripsInCoder()
371371
}
372372
}
373-
374-
static var allTests: [(String, (TestCharacterSet) -> () throws -> Void)] {
375-
return [
376-
("testBasicConstruction", testBasicConstruction),
377-
("testMutability_copyOnWrite", testMutability_copyOnWrite),
378-
("testRanges", testRanges),
379-
("testInsertAndRemove", testInsertAndRemove),
380-
("testBasics", testBasics),
381-
("testClosedRanges_SR_2988", testClosedRanges_SR_2988),
382-
("test_Predefines", test_Predefines),
383-
("test_Range", test_Range),
384-
("test_String", test_String),
385-
("test_Bitmap", test_Bitmap),
386-
("test_AnnexPlanes", test_AnnexPlanes),
387-
("test_Planes", test_Planes),
388-
("test_InlineBuffer", test_InlineBuffer),
389-
("test_Equatable", test_Equatable),
390-
("test_Subtracting", test_Subtracting),
391-
("test_SubtractEmptySet", test_SubtractEmptySet),
392-
("test_SubtractNonEmptySet", test_SubtractNonEmptySet),
393-
("test_SymmetricDifference", test_SymmetricDifference),
394-
("test_formUnion", test_formUnion),
395-
("test_union", test_union),
396-
("test_SR5971", test_SR5971),
397-
("test_hashing", test_hashing),
398-
("test_codingRoundtrip", test_codingRoundtrip),
399-
]
400-
}
401-
402-
403373
}

Tests/Foundation/TestCodable.swift

-25
Original file line numberDiff line numberDiff line change
@@ -547,28 +547,3 @@ class TestCodable : XCTestCase {
547547
}
548548
}
549549
}
550-
551-
extension TestCodable {
552-
static var allTests: [(String, (TestCodable) -> () throws -> Void)] {
553-
return [
554-
("test_PersonNameComponents_JSON", test_PersonNameComponents_JSON),
555-
("test_UUID_JSON", test_UUID_JSON),
556-
("test_URL_JSON", test_URL_JSON),
557-
("test_NSRange_JSON", test_NSRange_JSON),
558-
("test_Locale_JSON", test_Locale_JSON),
559-
("test_IndexSet_JSON", test_IndexSet_JSON),
560-
("test_IndexPath_JSON", test_IndexPath_JSON),
561-
("test_AffineTransform_JSON", test_AffineTransform_JSON),
562-
("test_Decimal_JSON", test_Decimal_JSON),
563-
("test_CGPoint_JSON", test_CGPoint_JSON),
564-
("test_CGSize_JSON", test_CGSize_JSON),
565-
("test_CGRect_JSON", test_CGRect_JSON),
566-
("test_CharacterSet_JSON", test_CharacterSet_JSON),
567-
("test_TimeZone_JSON", test_TimeZone_JSON),
568-
("test_Calendar_JSON", test_Calendar_JSON),
569-
("test_DateComponents_JSON", test_DateComponents_JSON),
570-
("test_Measurement_JSON", test_Measurement_JSON),
571-
("test_URLComponents_JSON", test_URLComponents_JSON),
572-
]
573-
}
574-
}

Tests/Foundation/TestDataURLProtocol.swift

-8
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,4 @@ class TestDataURLProtocol: XCTestCase {
147147
XCTAssertNil(delegate.response, "Unexpected URLResponse for \(urlString)")
148148
}
149149
}
150-
151-
static var allTests: [(String, (TestDataURLProtocol) -> () throws -> Void)] {
152-
let tests = [
153-
("test_validURIs", test_validURIs),
154-
("test_invalidURIs", test_invalidURIs),
155-
]
156-
return tests
157-
}
158150
}

Tests/Foundation/TestDate.swift

-23
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,6 @@ func dateWithString(_ str: String) -> Date {
1616
}
1717

1818
class TestDate : XCTestCase {
19-
20-
static var allTests: [(String, (TestDate) -> () throws -> Void)] {
21-
return [
22-
("test_BasicConstruction", test_BasicConstruction),
23-
("test_InitTimeIntervalSince1970", test_InitTimeIntervalSince1970),
24-
("test_InitTimeIntervalSinceSinceDate", test_InitTimeIntervalSinceSinceDate),
25-
("test_TimeIntervalSinceSinceDate", test_TimeIntervalSinceSinceDate),
26-
("test_descriptionWithLocale", test_descriptionWithLocale),
27-
("test_DistantFuture", test_DistantFuture),
28-
("test_DistantPast", test_DistantPast),
29-
("test_DateByAddingTimeInterval", test_DateByAddingTimeInterval),
30-
("test_EarlierDate", test_EarlierDate),
31-
("test_LaterDate", test_LaterDate),
32-
("test_Compare", test_Compare),
33-
("test_IsEqualToDate", test_IsEqualToDate),
34-
("test_timeIntervalSinceReferenceDate", test_timeIntervalSinceReferenceDate),
35-
("test_recreateDateComponentsFromDate", test_recreateDateComponentsFromDate),
36-
("test_Hashing", test_Hashing),
37-
("test_advancedBy", test_advancedBy),
38-
("test_distanceTo", test_distanceTo),
39-
]
40-
}
41-
4219
func test_BasicConstruction() {
4320
let d = Date()
4421
XCTAssert(d.timeIntervalSince1970 != 0)

Tests/Foundation/TestDateComponents.swift

-7
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,4 @@ class TestDateComponents: XCTestCase {
116116
dc.nanosecond = 6
117117
XCTAssertTrue(dc.isValidDate)
118118
}
119-
120-
static var allTests: [(String, (TestDateComponents) -> () throws -> Void)] {
121-
return [
122-
("test_hash", test_hash),
123-
("test_isValidDate", test_isValidDate),
124-
]
125-
}
126119
}

0 commit comments

Comments
 (0)