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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public import Foundation

/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
extension Attachable where Self: Encodable & NSSecureCoding {
@_documentation(visibility: private)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func withUnsafeBytes<E, R>(encoding attachableValue: borrowing E, for attachment

/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
extension Attachable where Self: Encodable {
/// Encode this value into a buffer using either [`PropertyListEncoder`](https://developer.apple.com/documentation/foundation/propertylistencoder)
Expand Down Expand Up @@ -92,6 +93,7 @@ extension Attachable where Self: Encodable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
try _Testing_Foundation.withUnsafeBytes(encoding: self, for: attachment, body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public import Foundation

/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
extension Attachable where Self: NSSecureCoding {
/// Encode this object using [`NSKeyedArchiver`](https://developer.apple.com/documentation/foundation/nskeyedarchiver)
Expand Down Expand Up @@ -52,6 +53,7 @@ extension Attachable where Self: NSSecureCoding {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
let format = try EncodingFormat(for: attachment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extension Attachment where AttachableValue == _AttachableURLWrapper {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public init(
contentsOf url: URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public import Foundation

/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
extension Data: Attachable {
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
try withUnsafeBytes(body)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Testing/Attachments/Attachable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public protocol Attachable: ~Copyable {
/// An estimate of the number of bytes of memory needed to store this value as
Expand All @@ -48,6 +49,7 @@ public protocol Attachable: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
var estimatedAttachmentByteCount: Int? { get }

Expand All @@ -74,6 +76,7 @@ public protocol Attachable: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
borrowing func withUnsafeBytes<R>(for attachment: borrowing Attachment<Self>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R

Expand All @@ -94,6 +97,7 @@ public protocol Attachable: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
borrowing func preferredName(for attachment: borrowing Attachment<Self>, basedOn suggestedName: String) -> String
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/Testing/Attachments/AttachableWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public protocol AttachableWrapper<Wrapped>: Attachable, ~Copyable {
/// The type of the underlying value represented by this type.
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
associatedtype Wrapped

/// The underlying value represented by this instance.
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
var wrappedValue: Wrapped { get }
}
11 changes: 11 additions & 0 deletions Sources/Testing/Attachments/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private import _TestingInternals
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Attachable & ~Copyable {
/// Storage for ``attachableValue-7dyjv``.
Expand Down Expand Up @@ -57,6 +58,7 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var preferredName: String {
let suggestedName = if let _preferredName, !_preferredName.isEmpty {
Expand Down Expand Up @@ -100,6 +102,7 @@ extension Attachment where AttachableValue: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public init(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation) {
self._attachableValue = attachableValue
Expand Down Expand Up @@ -194,6 +197,7 @@ extension Attachment where AttachableValue: ~Copyable {
extension Attachment: CustomStringConvertible {
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var description: String {
#""\#(preferredName)": \#(String(describingForTest: attachableValue))"#
Expand All @@ -207,6 +211,7 @@ extension Attachment where AttachableValue: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@_disfavoredOverload public var attachableValue: AttachableValue {
_read {
Expand All @@ -229,6 +234,7 @@ extension Attachment where AttachableValue: AttachableWrapper & ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var attachableValue: AttachableValue.Wrapped {
_read {
Expand Down Expand Up @@ -259,6 +265,7 @@ extension Attachment where AttachableValue: Sendable & Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@_documentation(visibility: private)
public static func record(_ attachment: consuming Self, sourceLocation: SourceLocation = #_sourceLocation) {
Expand Down Expand Up @@ -291,6 +298,7 @@ extension Attachment where AttachableValue: Sendable & Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@_documentation(visibility: private)
public static func record(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation) {
Expand Down Expand Up @@ -318,6 +326,7 @@ extension Attachment where AttachableValue: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static func record(_ attachment: consuming Self, sourceLocation: SourceLocation = #_sourceLocation) {
do {
Expand Down Expand Up @@ -361,6 +370,7 @@ extension Attachment where AttachableValue: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static func record(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation) {
record(Self(attachableValue, named: preferredName, sourceLocation: sourceLocation), sourceLocation: sourceLocation)
Expand Down Expand Up @@ -389,6 +399,7 @@ extension Attachment where AttachableValue: ~Copyable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@inlinable public borrowing func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
try attachableValue.withUnsafeBytes(for: self, body)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Testing/ExitTests/ExitStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private import _TestingInternals
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
#if SWT_NO_PROCESS_SPAWNING
@available(*, unavailable, message: "Exit tests are not available on this platform.")
Expand Down Expand Up @@ -55,6 +56,7 @@ public enum ExitStatus: Sendable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
case exitCode(_ exitCode: CInt)

Expand All @@ -81,6 +83,7 @@ public enum ExitStatus: Sendable {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
case signal(_ signal: CInt)
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/Testing/ExitTests/ExitTest.Condition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension ExitTest {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public struct Condition: Sendable {
/// An enumeration describing the possible conditions for an exit test.
Expand Down Expand Up @@ -66,6 +67,7 @@ extension ExitTest.Condition {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static var success: Self {
Self(_kind: .success)
Expand All @@ -78,6 +80,7 @@ extension ExitTest.Condition {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static var failure: Self {
Self(_kind: .failure)
Expand All @@ -91,6 +94,7 @@ extension ExitTest.Condition {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public init(_ exitStatus: ExitStatus) {
self.init(_kind: .exitStatus(exitStatus))
Expand Down Expand Up @@ -126,6 +130,7 @@ extension ExitTest.Condition {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static func exitCode(_ exitCode: CInt) -> Self {
#if !SWT_NO_EXIT_TESTS
Expand Down Expand Up @@ -158,6 +163,7 @@ extension ExitTest.Condition {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static func signal(_ signal: CInt) -> Self {
#if !SWT_NO_EXIT_TESTS
Expand Down
4 changes: 4 additions & 0 deletions Sources/Testing/ExitTests/ExitTest.Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ extension ExitTest {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public struct Result: Sendable {
/// The exit status reported by the process hosting the exit test.
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var exitStatus: ExitStatus

Expand Down Expand Up @@ -57,6 +59,7 @@ extension ExitTest {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var standardOutputContent: [UInt8] = []

Expand Down Expand Up @@ -87,6 +90,7 @@ extension ExitTest {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public var standardErrorContent: [UInt8] = []

Expand Down
2 changes: 2 additions & 0 deletions Sources/Testing/ExitTests/ExitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private import _TestingInternals
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
#if SWT_NO_EXIT_TESTS
@available(*, unavailable, message: "Exit tests are not available on this platform.")
Expand Down Expand Up @@ -170,6 +171,7 @@ extension ExitTest {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public static var current: ExitTest? {
_read {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Testing/Expectations/Expectation+Macro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ public macro require<R>(
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@freestanding(expression)
@discardableResult
Expand Down Expand Up @@ -559,6 +560,7 @@ public macro expect(
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
@freestanding(expression)
@discardableResult
Expand Down
1 change: 1 addition & 0 deletions Sources/Testing/Testing.docc/exit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors

@Metadata {
@Available(Swift, introduced: 6.2)
@Available(Xcode, introduced: 26.0)
}

Use exit tests to test functionality that might cause a test process to exit.
Expand Down
1 change: 1 addition & 0 deletions Sources/Testing/Traits/ConditionTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
///
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// @Available(Xcode, introduced: 26.0)
/// }
public func evaluate() async throws -> Bool {
switch kind {
Expand Down