Skip to content

Commit 6cbc73b

Browse files
Address build issues occurring when building with Library Evolution support, Xcode 16 (#133)
* Address build issues in Library Evolution mode Address build issues seen building for library evolution mode, Xcode 16 - i.e. `make build-for-library-evolution`. * Update ci.yml --------- Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
1 parent b22b6ae commit 6cbc73b

File tree

3 files changed

+98
-83
lines changed

3 files changed

+98
-83
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@v4
4040
- name: Select Xcode
41-
run: sudo xcode-select -s /Applications/Xcode_15.4.app
41+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
4242
- name: Run tests
4343
run: make build-for-library-evolution
4444

Sources/IssueReporting/ReportIssue.swift

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,7 @@ public func reportIssue(
3434
line: UInt = #line,
3535
column: UInt = #column
3636
) {
37-
switch TestContext.current {
38-
case .swiftTesting:
39-
_recordIssue(
40-
message: message(),
41-
fileID: "\(IssueContext.current?.fileID ?? fileID)",
42-
filePath: "\(IssueContext.current?.filePath ?? filePath)",
43-
line: Int(IssueContext.current?.line ?? line),
44-
column: Int(IssueContext.current?.column ?? column)
45-
)
46-
case .xcTest:
47-
_XCTFail(
48-
message().withAppHostWarningIfNeeded() ?? "",
49-
file: IssueContext.current?.filePath ?? filePath,
50-
line: IssueContext.current?.line ?? line
51-
)
52-
case nil:
37+
guard let context = TestContext.current else {
5338
guard !isTesting else { return }
5439
if let observer = FailureObserver.current {
5540
observer.withLock { $0 += 1 }
@@ -73,6 +58,25 @@ public func reportIssue(
7358
)
7459
}
7560
}
61+
return
62+
}
63+
64+
switch context {
65+
case .swiftTesting:
66+
_recordIssue(
67+
message: message(),
68+
fileID: "\(IssueContext.current?.fileID ?? fileID)",
69+
filePath: "\(IssueContext.current?.filePath ?? filePath)",
70+
line: Int(IssueContext.current?.line ?? line),
71+
column: Int(IssueContext.current?.column ?? column)
72+
)
73+
case .xcTest:
74+
_XCTFail(
75+
message().withAppHostWarningIfNeeded() ?? "",
76+
file: IssueContext.current?.filePath ?? filePath,
77+
line: IssueContext.current?.line ?? line
78+
)
79+
@unknown default: break
7680
}
7781
}
7882

@@ -97,23 +101,7 @@ public func reportIssue(
97101
line: UInt = #line,
98102
column: UInt = #column
99103
) {
100-
switch TestContext.current {
101-
case .swiftTesting:
102-
_recordError(
103-
error: error,
104-
message: message(),
105-
fileID: "\(IssueContext.current?.fileID ?? fileID)",
106-
filePath: "\(IssueContext.current?.filePath ?? filePath)",
107-
line: Int(IssueContext.current?.line ?? line),
108-
column: Int(IssueContext.current?.column ?? column)
109-
)
110-
case .xcTest:
111-
_XCTFail(
112-
"Caught error: \(error)\(message().map { ": \($0)" } ?? "")".withAppHostWarningIfNeeded(),
113-
file: IssueContext.current?.filePath ?? filePath,
114-
line: IssueContext.current?.line ?? line
115-
)
116-
case nil:
104+
guard let context = TestContext.current else {
117105
guard !isTesting else { return }
118106
if let observer = FailureObserver.current {
119107
observer.withLock { $0 += 1 }
@@ -139,5 +127,25 @@ public func reportIssue(
139127
)
140128
}
141129
}
130+
return
131+
}
132+
133+
switch context {
134+
case .swiftTesting:
135+
_recordError(
136+
error: error,
137+
message: message(),
138+
fileID: "\(IssueContext.current?.fileID ?? fileID)",
139+
filePath: "\(IssueContext.current?.filePath ?? filePath)",
140+
line: Int(IssueContext.current?.line ?? line),
141+
column: Int(IssueContext.current?.column ?? column)
142+
)
143+
case .xcTest:
144+
_XCTFail(
145+
"Caught error: \(error)\(message().map { ": \($0)" } ?? "")".withAppHostWarningIfNeeded(),
146+
file: IssueContext.current?.filePath ?? filePath,
147+
line: IssueContext.current?.line ?? line
148+
)
149+
@unknown default: break
142150
}
143151
}

Sources/IssueReporting/WithExpectedIssue.swift

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,7 @@ public func withExpectedIssue(
5151
column: UInt = #column,
5252
_ body: () throws -> Void
5353
) {
54-
switch TestContext.current {
55-
case .swiftTesting:
56-
_withKnownIssue(
57-
message,
58-
isIntermittent: isIntermittent,
59-
fileID: fileID.description,
60-
filePath: filePath.description,
61-
line: Int(line),
62-
column: Int(column),
63-
body
64-
)
65-
case .xcTest:
66-
_XCTExpectFailure(
67-
message.withAppHostWarningIfNeeded(),
68-
strict: !isIntermittent,
69-
file: filePath,
70-
line: line
71-
) {
72-
do {
73-
try body()
74-
} catch {
75-
reportIssue(error, fileID: fileID, filePath: filePath, line: line, column: column)
76-
}
77-
}
78-
case nil:
54+
guard let context = TestContext.current else {
7955
guard !isTesting else { return }
8056
let observer = FailureObserver()
8157
FailureObserver.$current.withValue(observer) {
@@ -107,6 +83,33 @@ public func withExpectedIssue(
10783
}
10884
return
10985
}
86+
87+
switch context {
88+
case .swiftTesting:
89+
_withKnownIssue(
90+
message,
91+
isIntermittent: isIntermittent,
92+
fileID: fileID.description,
93+
filePath: filePath.description,
94+
line: Int(line),
95+
column: Int(column),
96+
body
97+
)
98+
case .xcTest:
99+
_XCTExpectFailure(
100+
message.withAppHostWarningIfNeeded(),
101+
strict: !isIntermittent,
102+
file: filePath,
103+
line: line
104+
) {
105+
do {
106+
try body()
107+
} catch {
108+
reportIssue(error, fileID: fileID, filePath: filePath, line: line, column: column)
109+
}
110+
}
111+
@unknown default: break
112+
}
110113
}
111114

112115
/// Invoke an asynchronous function that has an issue that is expected to occur during its
@@ -137,31 +140,8 @@ public func withExpectedIssue(
137140
column: UInt = #column,
138141
_ body: () async throws -> Void
139142
) async {
140-
switch TestContext.current {
141-
case .swiftTesting:
142-
await _withKnownIssue(
143-
message,
144-
isIntermittent: isIntermittent,
145-
fileID: fileID.description,
146-
filePath: filePath.description,
147-
line: Int(line),
148-
column: Int(column),
149-
body
150-
)
151-
case .xcTest:
152-
reportIssue(
153-
"""
154-
Asynchronously expecting failures is unavailable in XCTest.
155143

156-
Omit this test from your XCTest suite, or consider using Swift Testing, instead.
157-
""",
158-
fileID: fileID,
159-
filePath: filePath,
160-
line: line,
161-
column: column
162-
)
163-
try? await body()
164-
case nil:
144+
guard let context = TestContext.current else {
165145
guard !isTesting else { return }
166146
let observer = FailureObserver()
167147
await FailureObserver.$current.withValue(observer) {
@@ -193,4 +173,31 @@ public func withExpectedIssue(
193173
}
194174
return
195175
}
176+
177+
switch context {
178+
case .swiftTesting:
179+
await _withKnownIssue(
180+
message,
181+
isIntermittent: isIntermittent,
182+
fileID: fileID.description,
183+
filePath: filePath.description,
184+
line: Int(line),
185+
column: Int(column),
186+
body
187+
)
188+
case .xcTest:
189+
reportIssue(
190+
"""
191+
Asynchronously expecting failures is unavailable in XCTest.
192+
193+
Omit this test from your XCTest suite, or consider using Swift Testing, instead.
194+
""",
195+
fileID: fileID,
196+
filePath: filePath,
197+
line: line,
198+
column: column
199+
)
200+
try? await body()
201+
@unknown default: break
202+
}
196203
}

0 commit comments

Comments
 (0)