diff --git a/Sources/Overlays/CMakeLists.txt b/Sources/Overlays/CMakeLists.txt index 2120d680f..5629e8229 100644 --- a/Sources/Overlays/CMakeLists.txt +++ b/Sources/Overlays/CMakeLists.txt @@ -1,9 +1,13 @@ # This source file is part of the Swift.org open source project # -# Copyright (c) 2024 Apple Inc. and the Swift project authors +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors +add_subdirectory(_Testing_AppKit) +add_subdirectory(_Testing_CoreGraphics) +add_subdirectory(_Testing_CoreImage) add_subdirectory(_Testing_Foundation) +add_subdirectory(_Testing_UIKit) diff --git a/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift index d62ef71cc..ef601f46f 100644 --- a/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,7 @@ #if SWT_TARGET_OS_APPLE && canImport(AppKit) public import AppKit -@_spi(Experimental) public import _Testing_CoreGraphics +public import _Testing_CoreGraphics extension NSImageRep { /// AppKit's bundle. @@ -33,8 +33,13 @@ extension NSImageRep { // MARK: - -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension NSImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { let ctm = AffineTransform(scale: _attachmentScaleFactor) as NSAffineTransform diff --git a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt new file mode 100644 index 000000000..75a463433 --- /dev/null +++ b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt @@ -0,0 +1,23 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_library(_Testing_AppKit + Attachments/NSImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_AppKit PUBLIC + Testing + _Testing_CoreGraphics) + + target_compile_options(_Testing_AppKit PRIVATE + -enable-library-evolution + -emit-module-interface -emit-module-interface-path $/_Testing_AppKit.swiftinterface) + + _swift_testing_install_target(_Testing_AppKit) +endif() diff --git a/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift b/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index e51742dc3..31427c9d7 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -13,12 +13,12 @@ public import CoreGraphics private import ImageIO /// A protocol describing images that can be converted to instances of -/// ``Testing/Attachment``. +/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment). /// /// Instances of types conforming to this protocol do not themselves conform to -/// ``Testing/Attachable``. Instead, the testing library provides additional -/// initializers on ``Testing/Attachment`` that take instances of such types and -/// handle converting them to image data when needed. +/// [`Attachable`](https://developer.apple.com/documentation/testing/attachable). +/// Instead, the testing library provides additional initializers on [`Attachment`](https://developer.apple.com/documentation/testing/attachment) +/// that take instances of such types and handle converting them to image data when needed. /// /// You can attach instances of the following system-provided image types to a /// test: @@ -27,17 +27,26 @@ private import ImageIO /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | +/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, /// first convert it to an instance of one of the types above. -@_spi(Experimental) +/// +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } @available(_uttypesAPI, *) public protocol AttachableAsCGImage: SendableMetatype { /// An instance of `CGImage` representing this image. /// /// - Throws: Any error that prevents the creation of an image. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } var attachableCGImage: CGImage { get throws } /// The orientation of the image. diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift index 173265807..4a0146c72 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift @@ -9,7 +9,7 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing public import UniformTypeIdentifiers @@ -64,6 +64,10 @@ extension AttachableImageFormat { /// The content type corresponding to this image format. /// /// The value of this property always conforms to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image). + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var contentType: UTType { switch kind { case .png: @@ -89,6 +93,10 @@ extension AttachableImageFormat { /// /// If `contentType` does not conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image), /// the result is undefined. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public init(_ contentType: UTType, encodingQuality: Float = 1.0) { precondition( contentType.conforms(to: .image), diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index b3349915b..65d90b11a 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -9,9 +9,8 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing -@_spi(Experimental) @available(_uttypesAPI, *) extension Attachment { /// Initialize an instance of this type that encloses the given image. @@ -33,7 +32,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -42,6 +43,10 @@ extension Attachment { /// specify a path extension, or if the path extension you specify doesn't /// correspond to an image format the operating system knows how to write, the /// testing library selects an appropriate image format for you. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public init( _ image: T, named preferredName: String? = nil, @@ -74,7 +79,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -83,8 +90,12 @@ extension Attachment { /// specify a path extension, or if the path extension you specify doesn't /// correspond to an image format the operating system knows how to write, the /// testing library selects an appropriate image format for you. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static func record( - _ image: consuming T, + _ image: T, named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift index 944798d39..c4a4fd630 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -11,8 +11,13 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) public import CoreGraphics -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension CGImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { self } diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 9976e769b..3281de11a 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -9,7 +9,7 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing private import CoreGraphics private import ImageIO @@ -39,7 +39,6 @@ private import UniformTypeIdentifiers /// useful.) @available(_uttypesAPI, *) -@_spi(Experimental) extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsCGImage { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { let data = NSMutableData() diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt new file mode 100644 index 000000000..335068a0b --- /dev/null +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -0,0 +1,26 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) + add_library(_Testing_CoreGraphics + Attachments/_AttachableImageWrapper+AttachableWrapper.swift + Attachments/AttachableAsCGImage.swift + Attachments/AttachableImageFormat+UTType.swift + Attachments/Attachment+AttachableAsCGImage.swift + Attachments/CGImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_CoreGraphics PUBLIC + Testing) + + target_compile_options(_Testing_CoreGraphics PRIVATE + -enable-library-evolution + -emit-module-interface -emit-module-interface-path $/_Testing_CoreGraphics.swiftinterface) + + _swift_testing_install_target(_Testing_CoreGraphics) +endif() diff --git a/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift b/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift index 5b28faa77..be2275d11 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift @@ -1,11 +1,11 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing +@_exported public import Testing diff --git a/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift index 7614dc633..581de2c7c 100644 --- a/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,10 +10,15 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreImage) public import CoreImage -@_spi(Experimental) public import _Testing_CoreGraphics +public import _Testing_CoreGraphics -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension CIImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { guard let result = CIContext().createCGImage(self, from: extent) else { diff --git a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt new file mode 100644 index 000000000..baa50537e --- /dev/null +++ b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt @@ -0,0 +1,23 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) + add_library(_Testing_CoreImage + Attachments/CIImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_CoreImage PUBLIC + Testing + _Testing_CoreGraphics) + + target_compile_options(_Testing_CoreImage PRIVATE + -enable-library-evolution + -emit-module-interface -emit-module-interface-path $/_Testing_CoreImage.swiftinterface) + + _swift_testing_install_target(_Testing_CoreImage) +endif() diff --git a/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift b/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift index 233f737a4..3766b3095 100644 --- a/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,16 +10,20 @@ #if SWT_TARGET_OS_APPLE && canImport(UIKit) public import UIKit -@_spi(Experimental) public import _Testing_CoreGraphics -@_spi(Experimental) private import _Testing_CoreImage +public import _Testing_CoreGraphics private import ImageIO #if canImport(UIKitCore_Private) private import UIKitCore_Private #endif -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension UIImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { #if canImport(UIKitCore_Private) diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt new file mode 100644 index 000000000..5976e2e86 --- /dev/null +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -0,0 +1,23 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) + add_library(_Testing_UIKit + Attachments/UIImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_UIKit PUBLIC + Testing + _Testing_CoreGraphics) + + target_compile_options(_Testing_UIKit PRIVATE + -enable-library-evolution + -emit-module-interface -emit-module-interface-path $/_Testing_UIKit.swiftinterface) + + _swift_testing_install_target(_Testing_UIKit) +endif() diff --git a/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift b/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Testing/Attachments/Images/AttachableImageFormat.swift b/Sources/Testing/Attachments/Images/AttachableImageFormat.swift index 4798e42b1..9bf6b50f8 100644 --- a/Sources/Testing/Attachments/Images/AttachableImageFormat.swift +++ b/Sources/Testing/Attachments/Images/AttachableImageFormat.swift @@ -12,7 +12,7 @@ /// when attaching an image to a test. /// /// When you attach an image to a test, you can pass an instance of this type to -/// ``Attachment/record(_:named:as:sourceLocation:)`` so that the testing +/// `Attachment.record(_:named:as:sourceLocation:)` so that the testing /// library knows the image format you'd like to use. If you don't pass an /// instance of this type, the testing library infers which format to use based /// on the attachment's preferred name. @@ -23,9 +23,14 @@ /// - On Apple platforms, you can use [`CGImageDestinationCopyTypeIdentifiers()`](https://developer.apple.com/documentation/imageio/cgimagedestinationcopytypeidentifiers()) /// from the [Image I/O framework](https://developer.apple.com/documentation/imageio) /// to determine which formats are supported. +/// @Comment { /// - On Windows, you can use [`IWICImagingFactory.CreateComponentEnumerator()`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentenumerator) /// to enumerate the available image encoders. -@_spi(Experimental) +/// } +/// +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } @available(_uttypesAPI, *) public struct AttachableImageFormat: Sendable { /// An enumeration describing the various kinds of image format that can be @@ -58,6 +63,10 @@ public struct AttachableImageFormat: Sendable { /// supported encoding quality and `1.0` being the highest supported encoding /// quality. The value of this property is ignored for image formats that do /// not support variable encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public internal(set) var encodingQuality: Float = 1.0 package init(kind: Kind, encodingQuality: Float) { @@ -71,11 +80,19 @@ public struct AttachableImageFormat: Sendable { @available(_uttypesAPI, *) extension AttachableImageFormat { /// The PNG image format. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static var png: Self { Self(kind: .png, encodingQuality: 1.0) } /// The JPEG image format with maximum encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static var jpeg: Self { Self(kind: .jpeg, encodingQuality: 1.0) } @@ -90,6 +107,10 @@ extension AttachableImageFormat { /// /// - Returns: An instance of this type representing the JPEG image format /// with the specified encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static func jpeg(withEncodingQuality encodingQuality: Float) -> Self { Self(kind: .jpeg, encodingQuality: encodingQuality) } diff --git a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift index 7cd6f8180..de421bfd9 100644 --- a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift +++ b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift index 71623538a..25e102677 100644 --- a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -17,8 +17,9 @@ /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | -@_spi(Experimental) +/// } @available(_uttypesAPI, *) public final class _AttachableImageWrapper: Sendable { /// The underlying image. diff --git a/Sources/Testing/Testing.docc/Attachments.md b/Sources/Testing/Testing.docc/Attachments.md index 0da40c201..e05fc0270 100644 --- a/Sources/Testing/Testing.docc/Attachments.md +++ b/Sources/Testing/Testing.docc/Attachments.md @@ -14,7 +14,7 @@ Attach values to tests to help diagnose issues and gather feedback. ## Overview -Attach values such as strings and files to tests. Implement the ``Attachable`` +Attach values such as strings and files to tests. Implement the ``Attachable`` protocol to create your own attachable types. ## Topics @@ -25,8 +25,18 @@ protocol to create your own attachable types. - ``Attachable`` - ``AttachableWrapper`` + + +### Attaching images to tests + +- ``AttachableImageFormat`` + diff --git a/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay new file mode 100644 index 000000000..cc9998ba3 --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_AppKit diff --git a/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay new file mode 100644 index 000000000..656012089 --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_CoreGraphics diff --git a/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay new file mode 100644 index 000000000..cdea5109b --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_CoreImage diff --git a/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay new file mode 100644 index 000000000..b3c35caed --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_UIKit diff --git a/Tests/TestingTests/AttachmentTests.swift b/Tests/TestingTests/AttachmentTests.swift index 84db8fe38..69793d215 100644 --- a/Tests/TestingTests/AttachmentTests.swift +++ b/Tests/TestingTests/AttachmentTests.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2023–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -12,7 +12,7 @@ private import _TestingInternals #if canImport(AppKit) && canImport(_Testing_AppKit) import AppKit -@_spi(Experimental) import _Testing_AppKit +import _Testing_AppKit #endif #if canImport(Foundation) && canImport(_Testing_Foundation) import Foundation @@ -24,11 +24,11 @@ import CoreGraphics #endif #if canImport(CoreImage) && canImport(_Testing_CoreImage) import CoreImage -@_spi(Experimental) import _Testing_CoreImage +import _Testing_CoreImage #endif #if canImport(UIKit) && canImport(_Testing_UIKit) import UIKit -@_spi(Experimental) import _Testing_UIKit +import _Testing_UIKit #endif #if canImport(UniformTypeIdentifiers) import UniformTypeIdentifiers