Skip to content

Commit 99ddc0f

Browse files
committed
Merge branch 'main' into jgrynspan/attachment-lifetimes-trait
2 parents 3ef8b2f + c996b0a commit 99ddc0f

File tree

56 files changed

+1609
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1609
-556
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ jobs:
1414
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1515
with:
1616
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
17+
linux_os_versions: '["amazonlinux2", "jammy"]'
1718
windows_swift_versions: '["nightly-main", "nightly-6.2"]'
1819
enable_macos_checks: true
19-
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.2\"}, {\"xcode_version\": \"16.3\"}]"
20+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.2\"}, {\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
2021
enable_wasm_sdk_build: true
2122
soundness:
2223
name: Soundness

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ if(POLICY CMP0157)
1919
endif()
2020
endif()
2121

22+
set(SWT_SOURCE_ROOT_DIR ${CMAKE_SOURCE_DIR})
23+
2224
project(SwiftTesting
2325
LANGUAGES CXX Swift)
2426

Package.swift

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.1
1+
// swift-tools-version: 6.2
22

33
//
44
// This source file is part of the Swift.org open source project
@@ -164,7 +164,7 @@ let package = Package(
164164
"Testing",
165165
],
166166
path: "Tests/_MemorySafeTestingTests",
167-
swiftSettings: .packageSettings + .strictMemorySafety
167+
swiftSettings: .packageSettings + [.strictMemorySafety()]
168168
),
169169

170170
.macro(
@@ -369,17 +369,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
369369
// proposal via Swift Evolution.
370370
.enableExperimentalFeature("SymbolLinkageMarkers"),
371371

372-
// This setting is no longer needed when building with a 6.2 or later
373-
// toolchain now that SE-0458 has been accepted and implemented, but it is
374-
// needed in order to preserve support for building with 6.1 development
375-
// snapshot toolchains. (Production 6.1 toolchains can build the testing
376-
// library even without this setting since this experimental feature is
377-
// _suppressible_.) This setting can be removed once the minimum supported
378-
// toolchain for building the testing library is ≥ 6.2. It is not needed
379-
// in the CMake settings since that is expected to build using a
380-
// new-enough toolchain.
381-
.enableExperimentalFeature("AllowUnsafeAttribute"),
382-
383372
.enableUpcomingFeature("InferIsolatedConformances"),
384373

385374
// When building as a package, the macro plugin always builds as an
@@ -394,6 +383,7 @@ extension Array where Element == PackageDescription.SwiftSetting {
394383
.define("SWT_NO_DYNAMIC_LINKING", .whenEmbedded(or: .when(platforms: [.wasi]))),
395384
.define("SWT_NO_PIPES", .whenEmbedded(or: .when(platforms: [.wasi]))),
396385
.define("SWT_NO_FOUNDATION_FILE_COORDINATION", .whenEmbedded(or: .whenApple(false))),
386+
.define("SWT_NO_IMAGE_ATTACHMENTS", .whenEmbedded(or: .when(platforms: [.linux, .custom("freebsd"), .openbsd, .wasi, .android]))),
397387

398388
.define("SWT_NO_LEGACY_TEST_DISCOVERY", .whenEmbedded()),
399389
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),
@@ -436,18 +426,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
436426

437427
return result
438428
}
439-
440-
/// Settings necessary to enable Strict Memory Safety, introduced in
441-
/// [SE-0458: Opt-in Strict Memory Safety Checking](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md#swiftpm-integration).
442-
static var strictMemorySafety: Self {
443-
#if compiler(>=6.2)
444-
// FIXME: Adopt official `.strictMemorySafety()` condition once the minimum
445-
// supported toolchain is 6.2.
446-
[.unsafeFlags(["-strict-memory-safety"])]
447-
#else
448-
[]
449-
#endif
450-
}
451429
}
452430

453431
extension Array where Element == PackageDescription.CXXSetting {

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private import ImageIO
3939
/// @Available(Swift, introduced: 6.3)
4040
/// }
4141
@available(_uttypesAPI, *)
42-
public protocol AttachableAsCGImage: SendableMetatype {
42+
public protocol AttachableAsCGImage: _AttachableAsImage, SendableMetatype {
4343
/// An instance of `CGImage` representing this image.
4444
///
4545
/// - Throws: Any error that prevents the creation of an image.
@@ -68,22 +68,6 @@ public protocol AttachableAsCGImage: SendableMetatype {
6868
/// This property is not part of the public interface of the testing
6969
/// library. It may be removed in a future update.
7070
var _attachmentScaleFactor: CGFloat { get }
71-
72-
/// Make a copy of this instance to pass to an attachment.
73-
///
74-
/// - Returns: A copy of `self`, or `self` if no copy is needed.
75-
///
76-
/// The testing library uses this function to take ownership of image
77-
/// resources that test authors pass to it. If possible, make a copy of or add
78-
/// a reference to `self`. If this type does not support making copies, return
79-
/// `self` verbatim.
80-
///
81-
/// The default implementation of this function when `Self` conforms to
82-
/// `Sendable` simply returns `self`.
83-
///
84-
/// This function is not part of the public interface of the testing library.
85-
/// It may be removed in a future update.
86-
func _copyAttachableValue() -> Self
8771
}
8872

8973
@available(_uttypesAPI, *)
@@ -95,6 +79,8 @@ extension AttachableAsCGImage {
9579
public var _attachmentScaleFactor: CGFloat {
9680
1.0
9781
}
82+
83+
public func _deinitializeAttachableValue() {}
9884
}
9985

10086
@available(_uttypesAPI, *)

Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ if(APPLE)
1111
Attachments/_AttachableImageWrapper+AttachableWrapper.swift
1212
Attachments/AttachableAsCGImage.swift
1313
Attachments/AttachableImageFormat+UTType.swift
14-
Attachments/Attachment+AttachableAsCGImage.swift
1514
Attachments/CGImage+AttachableAsCGImage.swift
1615
ReexportTesting.swift)
1716

Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public protocol _AttachableByAddressAsIWICBitmapSource {
113113
/// you have an image in another format that needs to be attached to a test,
114114
/// first convert it to an instance of one of the types above.
115115
@_spi(Experimental)
116-
public protocol AttachableAsIWICBitmapSource: SendableMetatype {
116+
public protocol AttachableAsIWICBitmapSource: _AttachableAsImage, SendableMetatype {
117117
/// Create a WIC bitmap source representing an instance of this type.
118118
///
119119
/// - Returns: A pointer to a new WIC bitmap source representing this image.
@@ -145,39 +145,6 @@ public protocol AttachableAsIWICBitmapSource: SendableMetatype {
145145
func _copyAttachableIWICBitmapSource(
146146
using factory: UnsafeMutablePointer<IWICImagingFactory>
147147
) throws -> UnsafeMutablePointer<IWICBitmapSource>
148-
149-
/// Make a copy of this instance.
150-
///
151-
/// - Returns: A copy of `self`, or `self` if this type does not support a
152-
/// copying operation.
153-
///
154-
/// The testing library uses this function to take ownership of image
155-
/// resources that test authors pass to it. If possible, make a copy of or add
156-
/// a reference to `self`. If this type does not support making copies, return
157-
/// `self` verbatim.
158-
///
159-
/// The default implementation of this function when `Self` conforms to
160-
/// `Sendable` simply returns `self`.
161-
///
162-
/// This function is not part of the public interface of the testing library.
163-
/// It may be removed in a future update.
164-
func _copyAttachableValue() -> Self
165-
166-
/// Manually deinitialize any resources associated with this image.
167-
///
168-
/// The implementation of this function cleans up any resources (such as
169-
/// handles or COM objects) associated with this image. The testing library
170-
/// automatically invokes this function as needed.
171-
///
172-
/// This function is not responsible for releasing the image returned from
173-
/// `_copyAttachableIWICBitmapSource(using:)`.
174-
///
175-
/// The default implementation of this function when `Self` conforms to
176-
/// `Sendable` does nothing.
177-
///
178-
/// This function is not part of the public interface of the testing library.
179-
/// It may be removed in a future update.
180-
func _deinitializeAttachableValue()
181148
}
182149

183150
extension AttachableAsIWICBitmapSource {
@@ -187,12 +154,4 @@ extension AttachableAsIWICBitmapSource {
187154
try copyAttachableIWICBitmapSource()
188155
}
189156
}
190-
191-
extension AttachableAsIWICBitmapSource where Self: Sendable {
192-
public func _copyAttachableValue() -> Self {
193-
self
194-
}
195-
196-
public func _deinitializeAttachableValue() {}
197-
}
198157
#endif

Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift

Lines changed: 0 additions & 107 deletions
This file was deleted.

Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private import Testing
1313
public import WinSDK
1414

1515
@_spi(Experimental)
16-
extension UnsafeMutablePointer: AttachableAsIWICBitmapSource where Pointee: _AttachableByAddressAsIWICBitmapSource {
16+
extension UnsafeMutablePointer: _AttachableAsImage, AttachableAsIWICBitmapSource where Pointee: _AttachableByAddressAsIWICBitmapSource {
1717
public func copyAttachableIWICBitmapSource() throws -> UnsafeMutablePointer<IWICBitmapSource> {
1818
let factory = try IWICImagingFactory.create()
1919
defer {
@@ -30,7 +30,7 @@ extension UnsafeMutablePointer: AttachableAsIWICBitmapSource where Pointee: _Att
3030
Pointee._copyAttachableValue(at: self)
3131
}
3232

33-
public consuming func _deinitializeAttachableValue() {
33+
public func _deinitializeAttachableValue() {
3434
Pointee._deinitializeAttachableValue(at: self)
3535
}
3636
}

Sources/Overlays/_Testing_WinSDK/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
1111
Attachments/_AttachableImageWrapper+AttachableWrapper.swift
1212
Attachments/AttachableAsIWICBitmapSource.swift
1313
Attachments/AttachableImageFormat+CLSID.swift
14-
Attachments/Attachment+AttachableAsIWICBitmapSource.swift
1514
Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift
1615
Attachments/HICON+AttachableAsIWICBitmapSource.swift
1716
Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift

Sources/Testing/Attachments/Images/AttachableImageFormat.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
/// @Metadata {
3232
/// @Available(Swift, introduced: 6.3)
3333
/// }
34+
#if SWT_NO_IMAGE_ATTACHMENTS
35+
@available(*, unavailable, message: "Image attachments are not available on this platform.")
36+
#endif
3437
@available(_uttypesAPI, *)
3538
public struct AttachableImageFormat: Sendable {
3639
/// An enumeration describing the various kinds of image format that can be
@@ -77,6 +80,9 @@ public struct AttachableImageFormat: Sendable {
7780

7881
// MARK: -
7982

83+
#if SWT_NO_IMAGE_ATTACHMENTS
84+
@available(*, unavailable, message: "Image attachments are not available on this platform.")
85+
#endif
8086
@available(_uttypesAPI, *)
8187
extension AttachableImageFormat {
8288
/// The PNG image format.

0 commit comments

Comments
 (0)