Skip to content

Commit 85f4e55

Browse files
authored
Always encode fallback events using the 6.3 record ABI (#1625)
Always encode fallback events using the 6.3 record ABI ### Motivation: This will make it easier to consume in swift-corelibs-xctest since we need to know ahead of time what JSON ABI to support there. Resolves rdar://172487645 ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 8a6cd8f commit 85f4e55

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Sources/Testing/Events/Event+FallbackEventHandler.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ extension Event {
247247
}
248248

249249
// Encode the event as JSON and pass it to the handler.
250-
return ABI.CurrentVersion.eventHandler(encodeAsJSONLines: false) { recordJSON in
250+
let abiVersion = ABI.v6_3.self
251+
return abiVersion.eventHandler(encodeAsJSONLines: false) { recordJSON in
251252
fallbackEventHandler(
252-
String(describing: ABI.CurrentVersion.versionNumber),
253+
String(describing: abiVersion.versionNumber),
253254
recordJSON.baseAddress!,
254255
recordJSON.count,
255256
nil

Tests/TestingTests/EventHandlingInteropTests.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ struct EventHandlingInteropTests {
7777
try Self.handlerContents.withLock {
7878
let contents = try #require(
7979
$0, "Fallback should have been called with non nil contents")
80-
#expect(contents.version == "\(ABI.CurrentVersion.versionNumber)")
81-
#expect(contents.record?.contains("A system failure occurred") ?? false)
80+
let versionNumberString = "\(ABI.v6_3.versionNumber)"
81+
#expect(contents.version == versionNumberString)
82+
#expect(contents.record?.contains(versionNumberString) == true)
83+
#expect(contents.record?.contains("A system failure occurred") == true)
8284
}
8385
}
8486
}
@@ -231,7 +233,7 @@ struct EventHandlingInteropTests {
231233
}
232234
}
233235

234-
@available(macOS 15.0, *) // String(validating:as:) is unavailable on older macOS
236+
@available(macOS 15.0, *) // String(validating:as:) is unavailable on older macOS
235237
@Test func `Strict interop mode causes a process exit`() async throws {
236238
let result = await #expect(processExitsWith: .failure, observing: [\.standardErrorContent]) {
237239
Self.enableExperimentalInterop()
@@ -244,7 +246,8 @@ struct EventHandlingInteropTests {
244246
}.run()
245247
}
246248

247-
let stderr = try #require(String(validating: result?.standardErrorContent ?? [UInt8](), as: UTF8.self))
249+
let stderr = try #require(
250+
String(validating: result?.standardErrorContent ?? [UInt8](), as: UTF8.self))
248251
#expect(stderr.contains("Fatal error: XCTest API was used in a Swift Testing test"))
249252
}
250253

@@ -274,7 +277,7 @@ struct EventHandlingInteropTests {
274277
/// This always forwards a test failure through the fallback event handler if it can find one.
275278
/// It is an error to call this when a handler hasn't been installed yet.
276279
/// - Parameter payload: Optional payload to use instead of generating a standard one.
277-
fileprivate func _FakeXCTFail(payload: Data? = nil) throws {
280+
private func _FakeXCTFail(payload: Data? = nil) throws {
278281
// A fallback event handler must be installed ahead of time
279282
let currentHandler = try #require(_swift_testing_getFallbackEventHandler())
280283

0 commit comments

Comments
 (0)