Skip to content

Commit 2be35c8

Browse files
author
Konstiantyn Gominyuk
committed
Fix FoundationTest build on macOS
FoundationTest build on macOS has been broken since swiftlang#2912. Compilation fails with error cannot convert value of type 'SwiftError' to type 'NSError' in coercion. I guess we have to exclude related tests on Darwin platform, but leave them in DarwinCompatibilityTests.
1 parent 3d5f197 commit 2be35c8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Tests/Foundation/Tests/TestNSError.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct SwiftCustomNSError: Error, CustomNSError {
1313
class TestNSError : XCTestCase {
1414

1515
static var allTests: [(String, (TestNSError) -> () throws -> Void)] {
16-
return [
16+
var tests: [(String, (TestNSError) -> () throws -> Void)] = [
1717
("test_LocalizedError_errorDescription", test_LocalizedError_errorDescription),
1818
("test_NSErrorAsError_localizedDescription", test_NSErrorAsError_localizedDescription),
1919
("test_NSError_inDictionary", test_NSError_inDictionary),
@@ -23,12 +23,19 @@ class TestNSError : XCTestCase {
2323
("test_CustomNSError_errorCodeRawInt", test_CustomNSError_errorCodeRawInt),
2424
("test_CustomNSError_errorCodeRawUInt", test_CustomNSError_errorCodeRawUInt),
2525
("test_errorConvenience", test_errorConvenience),
26+
]
27+
28+
#if !canImport(ObjectiveC) || DARWIN_COMPATIBILITY_TESTS
29+
tests.append(contentsOf: [
2630
("test_ConvertErrorToNSError_domain", test_ConvertErrorToNSError_domain),
2731
("test_ConvertErrorToNSError_errorCode", test_ConvertErrorToNSError_errorCode),
2832
("test_ConvertErrorToNSError_errorCodeRawInt", test_ConvertErrorToNSError_errorCodeRawInt),
2933
("test_ConvertErrorToNSError_errorCodeRawUInt", test_ConvertErrorToNSError_errorCodeRawUInt),
3034
("test_ConvertErrorToNSError_errorCodeWithAssosiatedValue", test_ConvertErrorToNSError_errorCodeWithAssosiatedValue),
31-
]
35+
])
36+
#endif
37+
38+
return tests
3239
}
3340

3441
func test_LocalizedError_errorDescription() {
@@ -112,6 +119,8 @@ class TestNSError : XCTestCase {
112119
}
113120
}
114121

122+
#if !canImport(ObjectiveC) || DARWIN_COMPATIBILITY_TESTS
123+
115124
func test_ConvertErrorToNSError_domain() {
116125
struct CustomSwiftError: Error {
117126
}
@@ -164,6 +173,8 @@ class TestNSError : XCTestCase {
164173
XCTAssertEqual((SwiftError.four as NSError).code, 4)
165174
XCTAssertEqual((SwiftError.five("five") as NSError).code, 1)
166175
}
176+
177+
#endif
167178

168179
}
169180

0 commit comments

Comments
 (0)