Skip to content

Commit d454328

Browse files
authored
Remove Snapshot types from non-Darwin builds. (#540)
Now that we've landed and tagged #479 in 0.11.0, we no longer need to keep building the snapshot types for non-Darwin platforms because we have a stable, permanent replacement for them. We need to keep them around on Darwin to support Xcode 16 betas. ### 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 4c368b3 commit d454328

File tree

17 files changed

+35
-3
lines changed

17 files changed

+35
-3
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ extension Array where Element == PackageDescription.SwiftSetting {
132132

133133
.define("SWT_NO_FILE_IO", .when(platforms: [.wasi])),
134134
.define("SWT_NO_EXIT_TESTS", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi])),
135+
.define("SWT_NO_SNAPSHOT_TYPES", .when(platforms: [.linux, .windows, .wasi])),
135136
]
136137
}
137138

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,12 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
512512
/// - Throws: If `version` is not a supported ABI version.
513513
func eventHandlerForStreamingEvents(version: Int?, forwardingTo eventHandler: @escaping @Sendable (UnsafeRawBufferPointer) -> Void) throws -> Event.Handler {
514514
switch version {
515+
#if !SWT_NO_SNAPSHOT_TYPES
515516
case -1:
516517
// Legacy support for Xcode 16 betas. Support for this undocumented version
517518
// will be removed in a future update. Do not use it.
518519
eventHandlerForStreamingEventSnapshots(to: eventHandler)
520+
#endif
519521
case nil, 0:
520522
ABIv0.Record.eventHandler(forwardingTo: eventHandler)
521523
case let .some(unsupportedVersion):
@@ -547,7 +549,7 @@ private func _writeJSONLine(_ json: UnsafeRawBufferPointer, to file: borrowing F
547549
if _slowPath(json.contains(where: isASCIINewline)) {
548550
#if DEBUG
549551
let message = Event.ConsoleOutputRecorder.warning(
550-
"JSON encoder produced one or more newline characters while encoding an event snapshot. Please file a bug report at https://github.com/apple/swift-testing/issues/new",
552+
"JSON encoder produced one or more newline characters while encoding an event to JSON. Please file a bug report at https://github.com/apple/swift-testing/issues/new",
551553
options: .for(.stderr)
552554
)
553555
#if SWT_TARGET_OS_APPLE

Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extension ABIv0.Record {
4545
}
4646
}
4747

48+
#if !SWT_NO_SNAPSHOT_TYPES
4849
// MARK: - Experimental event streaming
4950

5051
/// A type containing an event snapshot and snapshots of the contents of an
@@ -107,3 +108,4 @@ func eventHandlerForStreamingEventSnapshots(
107108
}
108109
}
109110
#endif
111+
#endif

Sources/Testing/Events/Event.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ extension Event {
287287
}
288288
}
289289

290+
#if !SWT_NO_SNAPSHOT_TYPES
290291
// MARK: - Snapshotting
291292

292293
extension Event {
@@ -509,3 +510,4 @@ extension Event.Context {
509510
}
510511
}
511512
}
513+
#endif

Sources/Testing/Expectations/Expectation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public struct ExpectationFailedError: Error {
5353
public var expectation: Expectation
5454
}
5555

56+
#if !SWT_NO_SNAPSHOT_TYPES
5657
// MARK: - Snapshotting
5758

5859
extension Expectation {
@@ -100,3 +101,4 @@ extension Expectation {
100101
}
101102
}
102103
}
104+
#endif

Sources/Testing/Issues/ErrorSnapshot.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11+
#if !SWT_NO_SNAPSHOT_TYPES
1112
/// A serializable snapshot of an `Error` value.
1213
///
1314
/// This type conforms to `Error` as well, meaning it can be thrown and treated
@@ -40,3 +41,4 @@ extension ErrorSnapshot: CustomStringConvertible {}
4041
// MARK: - Codable
4142

4243
extension ErrorSnapshot: Codable {}
44+
#endif

Sources/Testing/Issues/Issue.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ extension Issue.Kind: CustomStringConvertible {
194194
}
195195
}
196196

197+
#if !SWT_NO_SNAPSHOT_TYPES
197198
// MARK: - Snapshotting
198199

199200
extension Issue {
@@ -476,3 +477,4 @@ extension Issue.Kind.Snapshot: CustomStringConvertible {
476477
}
477478
}
478479
}
480+
#endif

Sources/Testing/Parameterization/Test.Case.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ extension Test.Case.Argument.ID: Codable {}
160160
extension Test.Parameter: Hashable {}
161161
extension Test.Case.Argument.ID: Hashable {}
162162

163+
#if !SWT_NO_SNAPSHOT_TYPES
163164
// MARK: - Snapshotting
164165

165166
extension Test.Case {
@@ -215,3 +216,4 @@ extension Test.Case.Argument {
215216
}
216217
}
217218
}
219+
#endif

Sources/Testing/Running/Runner.Plan.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ extension Runner.Plan {
303303
}
304304
}
305305

306+
#if !SWT_NO_SNAPSHOT_TYPES
306307
// MARK: - Snapshotting
307308

308309
extension Runner.Plan {
@@ -430,3 +431,4 @@ extension Runner.Plan.Action {
430431
}
431432
}
432433
}
434+
#endif

Sources/Testing/Test.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ extension Test: Equatable, Hashable {
271271
}
272272
}
273273

274+
#if !SWT_NO_SNAPSHOT_TYPES
274275
// MARK: - Snapshotting
275276

276277
extension Test {
@@ -388,3 +389,4 @@ extension Test {
388389
}
389390
}
390391
}
392+
#endif

0 commit comments

Comments
 (0)