Skip to content

Commit ebb4cc1

Browse files
authored
Remove @_implementationOnly imports guarded by 'SWT_BUILDING_WITH_CMAKE' (#554)
This removes the `SWT_BUILDING_WITH_CMAKE` compilation condition, and the `@_implementationOnly import _TestingInternals` declarations it guards. ### Motivation: When support for building via CMake was first added (in #387), many source files in the `Testing` target were modified to avoid using `private`- or `internal`-level imports of the `_TestingInternals` module and instead use the older `@_implementationOnly import` style when building via CMake. As a result, many files have: ```swift #if SWT_BUILDING_WITH_CMAKE @_implementationOnly import _TestingInternals #else private import _TestingInternals #endif ``` This has proven to be a maintenance problem for us, because as new files are added over time, it's not immediately obvious that they need to use this pattern for importing this module—leading to warnings when building with CMake such as the one fixed by #553. I wasn't aware of the reasoning behind the above change at the time, but I investigated it recently and here's what I concluded: Early on, the changes in #387 did _not_ enable Library Evolution (LE) for the `Testing` module, meaning it was still a non-resilient module. [SE-0409](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md) states that all dependencies of non-resilient modules must be loaded by clients, so it would make sense that under those conditions, the build of a client who imports `Testing` would fail because clients do not have visibility to the `_TestingInternals` module. However, in a later PR commit LE was enabled, but nobody realized that those `import` code changes were no longer necessary and could be reverted. I was able to reproduce this and confirm the theory: I added an example client target in the CMake build, then disabled LE in the `Testing` module, and attempted to build the client. It failed with the expected missing module error. Then, re-enabling LE and rebuilding everything, the error went away. Hopefully this is sufficient proof that reverting this is safe, but I'll check with the main contributor of that PR to check and see if there were any other issues before landing. But overall, the goal here is to simplify these imports to reduce maintenance burden and fully embrace SE-0409. ### 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 f0730c4 commit ebb4cc1

31 files changed

+0
-123
lines changed

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
/// The common implementation of the entry point functions in this package.
1814
///

Sources/Testing/ABI/EntryPoints/SwiftPMEntryPoint.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
/// The exit code returned to Swift Package Manager by Swift Testing when no
1814
/// tests matched the inputs specified by the developer (or, for the case of

Sources/Testing/Events/Clock.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
@_spi(Experimental) @_spi(ForToolsIntegrationOnly)
1814
extension Test {

Sources/Testing/Events/TimeValue.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
// `internal` because `TimeValue.init(_ timespec:)` below is internal and
1212
// references a type (`timespec`) which comes from this import.
13-
#if SWT_BUILDING_WITH_CMAKE
14-
@_implementationOnly import _TestingInternals
15-
#else
1613
internal import _TestingInternals
17-
#endif
1814

1915
/// A container type representing a time value that is suitable for storage,
2016
/// conversion, encoding, and decoding.

Sources/Testing/ExitTests/ExitCondition.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
/// An enumeration describing possible conditions under which an exit test will
1814
/// succeed or fail.

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
#if !SWT_NO_EXIT_TESTS
1814
/// A type describing an exit test.

Sources/Testing/ExitTests/WaitFor.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
#if !SWT_NO_EXIT_TESTS
1212

13-
#if SWT_BUILDING_WITH_CMAKE
14-
@_implementationOnly import _TestingInternals
15-
#else
1613
internal import _TestingInternals
17-
#endif
1814

1915
#if SWT_TARGET_OS_APPLE || os(Linux)
2016
/// Block the calling thread, wait for the target process to exit, and return

Sources/Testing/SourceAttribution/Backtrace.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
/// A type representing a backtrace or stack trace.
1814
@_spi(ForToolsIntegrationOnly)

Sources/Testing/Support/Additions/CommandLineAdditions.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
private import _TestingInternals
15-
#endif
1612

1713
extension CommandLine {
1814
/// The path to the current process' executable.

Sources/Testing/Support/CError.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if SWT_BUILDING_WITH_CMAKE
12-
@_implementationOnly import _TestingInternals
13-
#else
1411
internal import _TestingInternals
15-
#endif
1612

1713
/// A type representing an error from a C function such as `fopen()`.
1814
///

0 commit comments

Comments
 (0)