Skip to content

Commit 9da9a7a

Browse files
committed
Provide opt-out condition for sys_signame[].
This PR adds `SWT_NO_SYS_SIGNAME` which can be set in environments where the [`sys_signame[]`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sys_signame.3.html) array is not available.
1 parent 0b47e51 commit 9da9a7a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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:))

Tests/TestingTests/ExitTestTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ private import _TestingInternals
1616
@Test("Signal names are reported (where supported)") func signalName() {
1717
var hasSignalNames = false
1818
#if SWT_TARGET_OS_APPLE || os(FreeBSD) || os(OpenBSD) || os(Android)
19+
#if !SWT_NO_SYS_SIGNAME
1920
hasSignalNames = true
21+
#endif
2022
#elseif os(Linux) && !SWT_NO_DYNAMIC_LINKING
2123
hasSignalNames = (symbol(named: "sigabbrev_np") != nil)
2224
#endif

0 commit comments

Comments
 (0)