Skip to content

Commit 46b8d16

Browse files
authored
Merge branch 'main' into jgrynspan/typed-throws-in-expect
2 parents 2c361ab + c6512ff commit 46b8d16

22 files changed

+148
-41
lines changed

Sources/Testing/Events/Recorder/Event.AdvancedConsoleOutputRecorder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ extension Event {
142142
/// The write function for this recorder.
143143
let write: @Sendable (String) -> Void
144144

145-
/// The fallback console recorder for standard output.
146-
private let _fallbackRecorder: Event.ConsoleOutputRecorder
145+
/// The base console output options.
146+
private let _baseOptions: Event.ConsoleOutputRecorder.Options
147147

148148
/// Context storage for test information and results.
149149
private let _context: Locked<_Context>
@@ -159,7 +159,7 @@ extension Event {
159159
init(options: Options = Options(), writingUsing write: @escaping @Sendable (String) -> Void) {
160160
self.options = options
161161
self.write = write
162-
self._fallbackRecorder = Event.ConsoleOutputRecorder(options: options.base, writingUsing: write)
162+
self._baseOptions = options.base
163163
self._context = Locked(rawValue: _Context())
164164
self._humanReadableRecorder = Event.HumanReadableOutputRecorder()
165165
}
@@ -258,7 +258,7 @@ extension Event.AdvancedConsoleOutputRecorder {
258258
// The hierarchical summary will be shown at the end
259259
switch eventKind {
260260
case .runStarted:
261-
let symbol = Event.Symbol.default.stringValue(options: _fallbackRecorder.options)
261+
let symbol = Event.Symbol.default.stringValue(options: _baseOptions)
262262
write("\(symbol) Test run started.\n")
263263

264264
case .runEnded:

Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ extension Event.HumanReadableOutputRecorder {
361361
comments.append("Swift Standard Library Version: \(swiftStandardLibraryVersion)")
362362
}
363363
comments.append("Swift Compiler Version: \(swiftCompilerVersion)")
364-
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
364+
#if os(Linux) && canImport(Glibc)
365365
comments.append("GNU C Library Version: \(glibcVersion)")
366366
#endif
367367
}

Sources/Testing/ExitTests/ExitStatus.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ extension ExitStatus: CustomStringConvertible {
121121
var signalName: String?
122122

123123
#if SWT_TARGET_OS_APPLE || os(FreeBSD) || os(OpenBSD) || os(Android)
124+
#if !SWT_NO_SYS_SIGNAME
124125
// These platforms define sys_signame with a size, which is imported
125126
// into Swift as a tuple.
126127
withUnsafeBytes(of: sys_signame) { sys_signame in
@@ -130,6 +131,7 @@ extension ExitStatus: CustomStringConvertible {
130131
}
131132
}
132133
}
134+
#endif
133135
#elseif os(Linux)
134136
#if !SWT_NO_DYNAMIC_LINKING
135137
signalName = _sigabbrev_np?(signal).flatMap(String.init(validatingCString:))

Sources/Testing/ExitTests/ExitTest.CapturedValue.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ private import _TestingInternals
1212

1313
@_spi(ForToolsIntegrationOnly)
1414
#if SWT_NO_EXIT_TESTS
15+
@_unavailableInEmbedded
1516
@available(*, unavailable, message: "Exit tests are not available on this platform.")
1617
#endif
1718
extension ExitTest {

Sources/Testing/ExitTests/ExitTest.Condition.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
private import _TestingInternals
1212

1313
#if SWT_NO_EXIT_TESTS
14+
@_unavailableInEmbedded
1415
@available(*, unavailable, message: "Exit tests are not available on this platform.")
1516
#endif
1617
extension ExitTest {
@@ -58,6 +59,7 @@ extension ExitTest {
5859
// MARK: -
5960

6061
#if SWT_NO_EXIT_TESTS
62+
@_unavailableInEmbedded
6163
@available(*, unavailable, message: "Exit tests are not available on this platform.")
6264
#endif
6365
extension ExitTest.Condition {
@@ -177,6 +179,7 @@ extension ExitTest.Condition {
177179
// MARK: - CustomStringConvertible
178180

179181
#if SWT_NO_EXIT_TESTS
182+
@_unavailableInEmbedded
180183
@available(*, unavailable, message: "Exit tests are not available on this platform.")
181184
#endif
182185
extension ExitTest.Condition: CustomStringConvertible {
@@ -199,6 +202,7 @@ extension ExitTest.Condition: CustomStringConvertible {
199202
// MARK: - Comparison
200203

201204
#if SWT_NO_EXIT_TESTS
205+
@_unavailableInEmbedded
202206
@available(*, unavailable, message: "Exit tests are not available on this platform.")
203207
#endif
204208
extension ExitTest.Condition {

Sources/Testing/ExitTests/ExitTest.Result.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010

1111
#if SWT_NO_EXIT_TESTS
12+
@_unavailableInEmbedded
1213
@available(*, unavailable, message: "Exit tests are not available on this platform.")
1314
#endif
1415
extension ExitTest {

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ private import _TestingInternals
3535
/// @Available(Xcode, introduced: 26.0)
3636
/// }
3737
#if SWT_NO_EXIT_TESTS
38+
@_unavailableInEmbedded
3839
@available(*, unavailable, message: "Exit tests are not available on this platform.")
3940
#endif
4041
public struct ExitTest: Sendable, ~Copyable {

Sources/Testing/ExitTests/SpawnProcess.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ func spawnExecutable(
113113
withUnsafeTemporaryAllocation(of: sigset_t.self, capacity: 1) { allSignals in
114114
let allSignals = allSignals.baseAddress!
115115
sigfillset(allSignals)
116+
#if os(OpenBSD)
117+
// On OpenBSD, attempting to set the signal handler for SIGKILL or
118+
// SIGSTOP will cause the child process of a call to posix_spawn() to
119+
// exit abnormally with exit code 127. See https://man.openbsd.org/sigaction.2#ERRORS
120+
sigdelset(allSignals, SIGKILL)
121+
sigdelset(allSignals, SIGSTOP)
122+
#endif
116123
posix_spawnattr_setsigdefault(attrs, allSignals);
117124
flags |= CShort(POSIX_SPAWN_SETSIGDEF)
118125
}
@@ -137,7 +144,7 @@ func spawnExecutable(
137144
// standardized in POSIX.1-2024 (see https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_adddup2.html
138145
// and https://www.austingroupbugs.net/view.php?id=411).
139146
_ = posix_spawn_file_actions_adddup2(fileActions, fd, fd)
140-
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
147+
#if os(Linux) && canImport(Glibc)
141148
if _slowPath(glibcVersion < VersionNumber(2, 29)) {
142149
// This system is using an older version of glibc that does not
143150
// implement FD_CLOEXEC clearing in posix_spawn_file_actions_adddup2(),

Sources/Testing/ExitTests/WaitFor.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ private let _childProcessContinuations = LockedWith<pthread_mutex_t, [pid_t: Che
8585
/// A condition variable used to suspend the waiter thread created by
8686
/// `_createWaitThread()` when there are no child processes to await.
8787
private nonisolated(unsafe) let _waitThreadNoChildrenCondition = {
88-
#if os(FreeBSD) || os(OpenBSD)
89-
let result = UnsafeMutablePointer<pthread_cond_t?>.allocate(capacity: 1)
90-
#else
9188
let result = UnsafeMutablePointer<pthread_cond_t>.allocate(capacity: 1)
92-
#endif
9389
_ = pthread_cond_init(result, nil)
9490
return result
9591
}()

Sources/Testing/Expectations/Expectation+Macro.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ public macro require<R>(
882882
@freestanding(expression)
883883
@discardableResult
884884
#if SWT_NO_EXIT_TESTS
885+
@_unavailableInEmbedded
885886
@available(*, unavailable, message: "Exit tests are not available on this platform.")
886887
#endif
887888
public macro expect<E>(
@@ -929,6 +930,7 @@ public macro expect<E>(
929930
@freestanding(expression)
930931
@discardableResult
931932
#if SWT_NO_EXIT_TESTS
933+
@_unavailableInEmbedded
932934
@available(*, unavailable, message: "Exit tests are not available on this platform.")
933935
#endif
934936
public macro require<E>(

0 commit comments

Comments
 (0)