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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "Swift"
docs_check_container_image: "swift:6.2-noble"
docs_check_enabled: false
format_check_enabled: false
api_breakage_check_enabled: false
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ extension Array where Element == PackageDescription.SwiftSetting {
.define("SWT_NO_DYNAMIC_LINKING", .whenEmbedded(or: .when(platforms: [.wasi]))),
.define("SWT_NO_PIPES", .whenEmbedded(or: .when(platforms: [.wasi]))),
.define("SWT_NO_FOUNDATION_FILE_COORDINATION", .whenEmbedded(or: .whenApple(false))),
.define("SWT_NO_IMAGE_ATTACHMENTS", .whenEmbedded(or: .when(platforms: [.linux, .custom("freebsd"), .openbsd, .wasi, .android]))),

.define("SWT_NO_LEGACY_TEST_DISCOVERY", .whenEmbedded()),
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
public struct AttachableImageFormat: Sendable {
/// An enumeration describing the various kinds of image format that can be
Expand Down Expand Up @@ -77,6 +80,9 @@ public struct AttachableImageFormat: Sendable {

// MARK: -

#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
extension AttachableImageFormat {
/// The PNG image format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
extension Attachment {
/// Initialize an instance of this type that encloses the given image.
Expand Down Expand Up @@ -101,6 +104,9 @@ extension Attachment {
// MARK: -

@_spi(Experimental) // STOP: not part of ST-0014
#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
extension Attachment where AttachableValue: AttachableWrapper, AttachableValue.Wrapped: _AttachableAsImage {
/// The image format to use when encoding the represented image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
private import _TestingInternals

/// A type representing an error that can occur when attaching an image.
#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
package enum ImageAttachmentError: Error {
#if SWT_TARGET_OS_APPLE
/// The image could not be converted to an instance of `CGImage`.
Expand Down Expand Up @@ -39,6 +42,9 @@ package enum ImageAttachmentError: Error {
#endif
}

#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
extension ImageAttachmentError: CustomStringConvertible {
package var description: String {
#if SWT_TARGET_OS_APPLE
Expand Down
11 changes: 11 additions & 0 deletions Sources/Testing/Attachments/Images/_AttachableAsImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if SWT_TARGET_OS_APPLE
// Image attachments on Apple platforms conform to AttachableAsCGImage.
#elseif os(Windows)
// Image attachments on Windows platforms conform to AttachableAsIWICBitmapSource.
#elseif !SWT_NO_IMAGE_ATTACHMENTS
#error("Platform-specific misconfiguration: support for image attachments requires a platform-specific implementation")
#endif

/// A protocol describing images that can be converted to instances of
/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment).
///
Expand All @@ -18,6 +26,9 @@
/// A future Swift Evolution proposal will promote this protocol to API so
/// that we don't need to underscore its name.
/// }
#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
public protocol _AttachableAsImage: SendableMetatype {
/// Make a copy of this instance to pass to an attachment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
/// @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) |
/// }
#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
public final class _AttachableImageWrapper<Image>: Sendable where Image: _AttachableAsImage {
/// The underlying image.
Expand All @@ -38,6 +41,9 @@ public final class _AttachableImageWrapper<Image>: Sendable where Image: _Attach
}
}

#if SWT_NO_IMAGE_ATTACHMENTS
@available(*, unavailable, message: "Image attachments are not available on this platform.")
#endif
@available(_uttypesAPI, *)
extension _AttachableImageWrapper {
public var wrappedValue: Image {
Expand Down
3 changes: 3 additions & 0 deletions cmake/modules/shared/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
add_compile_definitions("SWT_NO_DYNAMIC_LINKING")
add_compile_definitions("SWT_NO_PIPES")
endif()
if (NOT (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Windows"))
add_compile_definitions("SWT_NO_IMAGE_ATTACHMENTS")
endif()

file(STRINGS "${SWT_SOURCE_ROOT_DIR}/VERSION.txt" SWT_TESTING_LIBRARY_VERSION LIMIT_COUNT 1)
if(SWT_TESTING_LIBRARY_VERSION)
Expand Down