Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ let package = Package(
],
exclude: ["CMakeLists.txt"],
cxxSettings: .packageSettings,
swiftSettings: .packageSettings
swiftSettings: .packageSettings,
linkerSettings: [
.linkedLibrary("execinfo", .when(platforms: [.custom("freebsd")]))
]
),
.testTarget(
name: "TestingTests",
Expand Down Expand Up @@ -114,7 +117,7 @@ let package = Package(
)

// BUG: swift-package-manager-#6367
#if !os(Windows)
#if !os(Windows) && !os(FreeBSD)
package.targets.append(contentsOf: [
.testTarget(
name: "TestingMacrosTests",
Expand Down Expand Up @@ -143,7 +146,7 @@ extension Array where Element == PackageDescription.SwiftSetting {

.define("SWT_NO_EXIT_TESTS", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi, .android])),
.define("SWT_NO_PROCESS_SPAWNING", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi, .android])),
.define("SWT_NO_SNAPSHOT_TYPES", .when(platforms: [.linux, .windows, .wasi])),
.define("SWT_NO_SNAPSHOT_TYPES", .when(platforms: [.linux, .custom("freebsd"), .windows, .wasi])),
.define("SWT_NO_DYNAMIC_LINKING", .when(platforms: [.wasi])),
.define("SWT_NO_PIPES", .when(platforms: [.wasi])),
]
Expand Down Expand Up @@ -178,7 +181,7 @@ extension Array where Element == PackageDescription.CXXSetting {
result += [
.define("SWT_NO_EXIT_TESTS", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi, .android])),
.define("SWT_NO_PROCESS_SPAWNING", .when(platforms: [.iOS, .watchOS, .tvOS, .visionOS, .wasi, .android])),
.define("SWT_NO_SNAPSHOT_TYPES", .when(platforms: [.linux, .windows, .wasi])),
.define("SWT_NO_SNAPSHOT_TYPES", .when(platforms: [.linux, .custom("freebsd"), .windows, .wasi])),
.define("SWT_NO_DYNAMIC_LINKING", .when(platforms: [.wasi])),
.define("SWT_NO_PIPES", .when(platforms: [.wasi])),
]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/SourceAttribution/Backtrace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ extension Backtrace {
/// crash. To avoid said crash, we'll keep a strong reference to the
/// object (abandoning memory until the process exits.)
/// ([swift-#62985](https://github.com/swiftlang/swift/issues/62985))
#if os(Windows)
#if os(Windows) || os(FreeBSD)
nonisolated(unsafe) var errorObject: AnyObject?
#else
nonisolated(unsafe) weak var errorObject: AnyObject?
Expand Down
6 changes: 6 additions & 0 deletions Sources/Testing/Support/CError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func strerror(_ errorCode: CInt) -> String {
_ = strerror_s(buffer.baseAddress!, buffer.count, errorCode)
return strnlen(buffer.baseAddress!, buffer.count)
}
#elseif os(FreeBSD)
// FreeBSD's implementation of strerror() is not thread-safe.
String(unsafeUninitializedCapacity: 1024) { buffer in
_ = strerror_r(errorCode, buffer.baseAddress!, buffer.count)
return strnlen(buffer.baseAddress!, buffer.count)
}
#else
String(cString: _TestingInternals.strerror(errorCode))
#endif
Expand Down