Skip to content

Commit 3fb80df

Browse files
authored
Fix some compiler conditional uses (SWT_NO_*). (#782)
This PR fixes a few edge cases where combinations of feature-disabling compiler conditionals would make the build fail. ### 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 19329a4 commit 3fb80df

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Diff for: Sources/Testing/ABI/EntryPoints/EntryPoint.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
533533
return configuration
534534
}
535535

536-
#if canImport(Foundation) && !SWT_NO_FILE_IO
536+
#if canImport(Foundation) && (!SWT_NO_FILE_IO || !SWT_NO_ABI_ENTRY_POINT)
537537
/// Create an event handler that streams events to the given file using the
538538
/// specified ABI version.
539539
///

Diff for: Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ extension ABIv0.Record {
2121
// We don't actually expect the JSON encoder to produce output containing
2222
// newline characters, so in debug builds we'll log a diagnostic message.
2323
if _slowPath(json.contains(where: \.isASCIINewline)) {
24-
#if DEBUG
24+
#if DEBUG && !SWT_NO_FILE_IO
2525
let message = Event.ConsoleOutputRecorder.warning(
2626
"JSON encoder produced one or more newline characters while encoding an event to JSON. Please file a bug report at https://github.com/swiftlang/swift-testing/issues/new",
2727
options: .for(.stderr)
2828
)
29-
#if SWT_TARGET_OS_APPLE
29+
#if SWT_TARGET_OS_APPLE
3030
try? FileHandle.stderr.write(message)
31-
#else
31+
#else
3232
print(message)
33-
#endif
34-
#endif
33+
#endif
34+
#endif
3535

3636
// Remove the newline characters to conform to JSON lines specification.
3737
var json = Array(json)

Diff for: Sources/Testing/ExitTests/ExitTest.swift

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
private import _TestingInternals
1212

1313
#if !SWT_NO_EXIT_TESTS
14+
#if SWT_NO_FILE_IO
15+
#error("Platform-specific misconfiguration: support for exit tests requires support for file I/O")
16+
#endif
1417
#if SWT_NO_PIPES
1518
#error("Platform-specific misconfiguration: support for exit tests requires support for (anonymous) pipes")
1619
#endif

Diff for: Sources/Testing/ExitTests/SpawnProcess.swift

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
internal import _TestingInternals
1212

1313
#if !SWT_NO_PROCESS_SPAWNING
14+
#if SWT_NO_FILE_IO
15+
#error("Platform-specific misconfiguration: support for process spawning requires support for file I/O")
16+
#endif
17+
1418
/// A platform-specific value identifying a process running on the current
1519
/// system.
1620
#if SWT_TARGET_OS_APPLE || os(Linux) || os(FreeBSD)

0 commit comments

Comments
 (0)