Skip to content

Update documentation to explain misconfigurations of SWT_ conditions. #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
10 changes: 10 additions & 0 deletions Documentation/Porting.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ These warnings may be emitted by our internal C++ module (`_TestingInternals`)
or by our library module (`Testing`). Both indicate areas of our code that need
platform-specific attention.

> [!NOTE]
> Rarely, you may encounter errors of a similar form:
>
> > 🛑 ERROR: Platform-specific misconfiguration: ...
>
> These errors are produced when the configuration you're trying to build has
> conflicting requirements (for example, attempting to enable support for pipes
> without also enabling support for file I/O.) You should be able to resolve
> these issues by updating Package.swift and/or CompilerSettings.cmake.

Most platform dependencies can be resolved through the use of platform-specific
API. For example, Swift Testing uses the C11 standard [`timespec`](https://en.cppreference.com/w/c/chrono/timespec)
type to accurately track the durations of test runs. If you are porting Swift
Expand Down
20 changes: 14 additions & 6 deletions Sources/Testing/ExitTests/ExitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

private import _TestingInternals

#if !SWT_NO_EXIT_TESTS
#if SWT_NO_PIPES
#error("Platform-specific misconfiguration: support for exit tests requires support for (anonymous) pipes")
#endif
#if SWT_NO_PROCESS_SPAWNING
#error("Platform-specific misconfiguration: support for exit tests requires support for process spawning")
#endif
#endif

/// A type describing an exit test.
///
/// Instances of this type describe an exit test defined by the test author and
Expand All @@ -19,7 +28,6 @@ private import _TestingInternals
@available(*, unavailable, message: "Exit tests are not available on this platform.")
#endif
public struct ExitTest: Sendable, ~Copyable {
#if !SWT_NO_EXIT_TESTS
/// The expected exit condition of the exit test.
@_spi(ForToolsIntegrationOnly)
public var expectedExitCondition: ExitCondition
Expand All @@ -33,7 +41,12 @@ public struct ExitTest: Sendable, ~Copyable {
/// processes, so it can be used to uniquely identify an exit test at runtime.
@_spi(ForToolsIntegrationOnly)
public var sourceLocation: SourceLocation
}

#if !SWT_NO_EXIT_TESTS
// MARK: - Invocation

extension ExitTest {
/// Disable crash reporting, crash logging, or core dumps for the current
/// process.
private static func _disableCrashReporting() {
Expand Down Expand Up @@ -100,13 +113,8 @@ public struct ExitTest: Sendable, ~Copyable {
let expectingFailure = expectedExitCondition == .failure
exit(expectingFailure ? EXIT_SUCCESS : EXIT_FAILURE)
}
#endif
}

#if !SWT_NO_EXIT_TESTS
#if SWT_NO_PIPES
#error("Support for exit tests requires support for (anonymous) pipes.")
#endif
// MARK: - Discovery

/// A protocol describing a type that contains an exit test.
Expand Down
6 changes: 6 additions & 0 deletions Sources/Testing/Support/FileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

internal import _TestingInternals

#if !SWT_NO_PIPES
#if SWT_NO_FILE_IO
#error("Platform-specific misconfiguration: support for (anonymous) pipes requires support for file I/O")
#endif
#endif

#if !SWT_NO_FILE_IO
/// A type representing a file handle.
///
Expand Down