From 8654f5fff8c4d87e2c29a1ee0340395278a55226 Mon Sep 17 00:00:00 2001 From: Stuart Montgomery Date: Wed, 12 Feb 2025 11:53:32 -0600 Subject: [PATCH 1/2] Declare a package name for CMake builds and remove @_spi(ForSwiftTestingOnly) --- Documentation/SPI.md | 14 -------------- .../Attachment+AttachableAsCGImage.swift | 2 +- .../Attachments/ImageAttachmentError.swift | 3 +-- .../Attachments/Attachment+URL.swift | 2 +- Sources/Testing/Attachments/Attachment.swift | 3 +-- Tests/TestingTests/AttachmentTests.swift | 2 +- cmake/modules/shared/CompilerSettings.cmake | 2 ++ 7 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Documentation/SPI.md b/Documentation/SPI.md index 534d6e51f..766043f44 100644 --- a/Documentation/SPI.md +++ b/Documentation/SPI.md @@ -39,14 +39,6 @@ external tools, _both_ groups are specified. Such SPI is not generally meant to be promoted to public API, but is still experimental until tools authors have a chance to evaluate it. -For interfaces internal to Swift Testing that must be available across targets, -the SPI group `@_spi(ForSwiftTestingOnly)` is used. They _should_ be marked -`package` and may be in the future, but are currently exported due to technical -constraints when Swift Testing is built using CMake. - -> [!WARNING] -> Never use symbols marked `@_spi(ForSwiftTestingOnly)`. - ## SPI stability The testing library does **not** guarantee SPI stability for either group of @@ -59,12 +51,6 @@ to newer interfaces. SPI marked `@_spi(Experimental)` should be assumed to be unstable. It may be modified or removed at any time. -SPI marked `@_spi(ForSwiftTestingOnly)` is unstable and subject to change at any -time. - -> [!WARNING] -> Never use symbols marked `@_spi(ForSwiftTestingOnly)`. - ## API and ABI stability When Swift Testing reaches its 1.0 release, API changes will follow the same diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index ddc876442..ca520e0c0 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -9,7 +9,7 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(ForSwiftTestingOnly) @_spi(Experimental) public import Testing +@_spi(Experimental) public import Testing public import UniformTypeIdentifiers diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift index b63831317..88b5f7458 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift @@ -10,8 +10,7 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) /// A type representing an error that can occur when attaching an image. -@_spi(ForSwiftTestingOnly) -public enum ImageAttachmentError: Error, CustomStringConvertible { +enum ImageAttachmentError: Error, CustomStringConvertible { /// The image could not be converted to an instance of `CGImage`. case couldNotCreateCGImage diff --git a/Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift b/Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift index 305bdd35b..dbf7e2688 100644 --- a/Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift +++ b/Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift @@ -9,7 +9,7 @@ // #if canImport(Foundation) -@_spi(Experimental) @_spi(ForSwiftTestingOnly) public import Testing +@_spi(Experimental) public import Testing public import Foundation #if !SWT_NO_PROCESS_SPAWNING && os(Windows) diff --git a/Sources/Testing/Attachments/Attachment.swift b/Sources/Testing/Attachments/Attachment.swift index f69df3679..ceaf1a5d5 100644 --- a/Sources/Testing/Attachments/Attachment.swift +++ b/Sources/Testing/Attachments/Attachment.swift @@ -37,8 +37,7 @@ public struct Attachment: ~Copyable where AttachableValue: Atta public var fileSystemPath: String? /// The default preferred name to use if the developer does not supply one. - @_spi(ForSwiftTestingOnly) - public static var defaultPreferredName: String { + private static var defaultPreferredName: String { "untitled" } diff --git a/Tests/TestingTests/AttachmentTests.swift b/Tests/TestingTests/AttachmentTests.swift index 98ecc668d..3fa979b35 100644 --- a/Tests/TestingTests/AttachmentTests.swift +++ b/Tests/TestingTests/AttachmentTests.swift @@ -16,7 +16,7 @@ import Foundation #endif #if canImport(CoreGraphics) import CoreGraphics -@_spi(Experimental) @_spi(ForSwiftTestingOnly) import _Testing_CoreGraphics +@_spi(Experimental) import _Testing_CoreGraphics #endif #if canImport(UniformTypeIdentifiers) import UniformTypeIdentifiers diff --git a/cmake/modules/shared/CompilerSettings.cmake b/cmake/modules/shared/CompilerSettings.cmake index 49e2579fe..eb9da4162 100644 --- a/cmake/modules/shared/CompilerSettings.cmake +++ b/cmake/modules/shared/CompilerSettings.cmake @@ -8,6 +8,8 @@ # Settings intended to be applied to every Swift target in this project. # Analogous to project-level build settings in an Xcode project. +add_compile_options( + "SHELL:$<$:-package-name org.swift.testing>") add_compile_options( "SHELL:$<$:-Xfrontend -require-explicit-sendable>") add_compile_options( From 033e7cbba49dc2b1ff9850d978e3d1694a2085d2 Mon Sep 17 00:00:00 2001 From: Stuart Montgomery Date: Wed, 12 Feb 2025 13:04:58 -0600 Subject: [PATCH 2/2] Change two decls to be `package` --- .../Attachments/ImageAttachmentError.swift | 2 +- Sources/Testing/Attachments/Attachment.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift index 88b5f7458..f957888b7 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift @@ -10,7 +10,7 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) /// A type representing an error that can occur when attaching an image. -enum ImageAttachmentError: Error, CustomStringConvertible { +package enum ImageAttachmentError: Error, CustomStringConvertible { /// The image could not be converted to an instance of `CGImage`. case couldNotCreateCGImage diff --git a/Sources/Testing/Attachments/Attachment.swift b/Sources/Testing/Attachments/Attachment.swift index ceaf1a5d5..ef7ae5537 100644 --- a/Sources/Testing/Attachments/Attachment.swift +++ b/Sources/Testing/Attachments/Attachment.swift @@ -37,7 +37,7 @@ public struct Attachment: ~Copyable where AttachableValue: Atta public var fileSystemPath: String? /// The default preferred name to use if the developer does not supply one. - private static var defaultPreferredName: String { + package static var defaultPreferredName: String { "untitled" }