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
10 changes: 5 additions & 5 deletions Sources/Testing/Attachments/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ extension Attachment where AttachableValue == AnyAttachable {
/// events of kind ``Event/Kind/valueAttached(_:)``. Test tools authors who use
/// `@_spi(ForToolsIntegrationOnly)` will see instances of this type when
/// handling those events.
//
// @Comment {
// Swift's type system requires that this type be at least as visible as
// `Event.Kind.valueAttached(_:)`, otherwise it would be declared private.
// }
///
/// @Comment {
/// Swift's type system requires that this type be at least as visible as
/// `Event.Kind.valueAttached(_:)`, otherwise it would be declared private.
/// }
@_spi(ForToolsIntegrationOnly)
public struct AnyAttachable: AttachableWrapper, Copyable, Sendable {
#if !SWT_NO_LAZY_ATTACHMENTS
Expand Down
10 changes: 6 additions & 4 deletions Sources/Testing/Expectations/Expectation+Macro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,12 @@ public macro require<R>(
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// }
@freestanding(expression)
@discardableResult
#if SWT_NO_EXIT_TESTS
@available(*, unavailable, message: "Exit tests are not available on this platform.")
#endif
@discardableResult
@freestanding(expression) public macro expect(
public macro expect(
processExitsWith expectedExitCondition: ExitTest.Condition,
observing observedValues: [any PartialKeyPath<ExitTest.Result> & Sendable] = [],
_ comment: @autoclosure () -> Comment? = nil,
Expand Down Expand Up @@ -559,11 +560,12 @@ public macro require<R>(
/// @Metadata {
/// @Available(Swift, introduced: 6.2)
/// }
@freestanding(expression)
@discardableResult
#if SWT_NO_EXIT_TESTS
@available(*, unavailable, message: "Exit tests are not available on this platform.")
#endif
@discardableResult
@freestanding(expression) public macro require(
public macro require(
processExitsWith expectedExitCondition: ExitTest.Condition,
observing observedValues: [any PartialKeyPath<ExitTest.Result> & Sendable] = [],
_ comment: @autoclosure () -> Comment? = nil,
Expand Down
24 changes: 12 additions & 12 deletions Sources/Testing/Issues/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public struct Issue: Sendable {
///
/// - Parameters:
/// - timeLimitComponents: The time limit reached by the test.
//
// @Comment {
// - Bug: The associated value of this enumeration case should be an
// instance of `Duration`, but the testing library's deployment target
// predates the introduction of that type.
// }
///
/// @Comment {
/// - Bug: The associated value of this enumeration case should be an
/// instance of `Duration`, but the testing library's deployment target
/// predates the introduction of that type.
/// }
indirect case timeLimitExceeded(timeLimitComponents: (seconds: Int64, attoseconds: Int64))

/// A known issue was expected, but was not recorded.
Expand Down Expand Up @@ -434,12 +434,12 @@ extension Issue.Kind {
///
/// - Parameters:
/// - timeLimitComponents: The time limit reached by the test.
//
// @Comment {
// - Bug: The associated value of this enumeration case should be an
// instance of `Duration`, but the testing library's deployment target
// predates the introduction of that type.
// }
///
/// @Comment {
/// - Bug: The associated value of this enumeration case should be an
/// instance of `Duration`, but the testing library's deployment target
/// predates the introduction of that type.
/// }
indirect case timeLimitExceeded(timeLimitComponents: (seconds: Int64, attoseconds: Int64))

/// A known issue was expected, but was not recorded.
Expand Down
30 changes: 15 additions & 15 deletions Sources/Testing/Parameterization/Test.Case.Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ extension Test.Case {
/// a known collection of argument values.
///
/// Instances of this type can be iterated over multiple times.
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
struct Generator<S>: Sendable where S: Sequence & Sendable, S.Element: Sendable {
/// The underlying sequence of argument values.
///
Expand Down Expand Up @@ -146,11 +146,11 @@ extension Test.Case {
///
/// This initializer overload is specialized for sequences of 2-tuples to
/// efficiently de-structure their elements when appropriate.
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
private init<E1, E2>(
sequence: S,
parameters: [Test.Parameter],
Expand Down Expand Up @@ -184,11 +184,11 @@ extension Test.Case {
///
/// This initializer overload is specialized for collections of 2-tuples to
/// efficiently de-structure their elements when appropriate.
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
init<E1, E2>(
arguments collection: S,
parameters: [Test.Parameter],
Expand Down
4 changes: 2 additions & 2 deletions Sources/Testing/Running/Runner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extension Runner {
in sequence: some Sequence<E>,
_ body: @Sendable @escaping (E) async throws -> Void
) async throws where E: Sendable {
try await withThrowingTaskGroup(of: Void.self) { taskGroup in
try await withThrowingTaskGroup { taskGroup in
for element in sequence {
// Each element gets its own subtask to run in.
_ = taskGroup.addTaskUnlessCancelled {
Expand Down Expand Up @@ -430,7 +430,7 @@ extension Runner {
Event.post(.iterationEnded(iterationIndex), for: (nil, nil), configuration: runner.configuration)
}

await withTaskGroup(of: Void.self) { [runner] taskGroup in
await withTaskGroup { [runner] taskGroup in
_ = taskGroup.addTaskUnlessCancelled {
try? await _runStep(atRootOf: runner.plan.stepGraph)
}
Expand Down
20 changes: 10 additions & 10 deletions Sources/Testing/Support/CartesianProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/// `[(1, "a"), (1, "b"), (1, "c"), (2, "a"), (2, "b"), ... (3, "c")]`.
///
/// This type is not part of the public interface of the testing library.
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
struct CartesianProduct<C1, C2>: LazySequenceProtocol where C1: Collection, C2: Collection {
fileprivate var collection1: C1
fileprivate var collection2: C2
Expand Down Expand Up @@ -63,11 +63,11 @@ extension CartesianProduct: Sendable where C1: Sendable, C2: Sendable {}
/// while `collection2` is iterated `collection1.count` times.
///
/// For more information on Cartesian products, see ``CartesianProduct``.
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
func cartesianProduct<C1, C2>(_ collection1: C1, _ collection2: C2) -> CartesianProduct<C1, C2> where C1: Collection, C2: Collection {
CartesianProduct(collection1: collection1, collection2: collection2)
}
4 changes: 2 additions & 2 deletions Sources/Testing/Test+Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension Test {
// a task group and collate their results.
if useNewMode {
let generators = Generator.allTestContentRecords().lazy.compactMap { $0.load() }
await withTaskGroup(of: Self.self) { taskGroup in
await withTaskGroup { taskGroup in
for generator in generators {
taskGroup.addTask { await generator.rawValue() }
}
Expand All @@ -96,7 +96,7 @@ extension Test {
// Perform legacy test discovery if needed.
if useLegacyMode && result.isEmpty {
let generators = Generator.allTypeMetadataBasedTestContentRecords().lazy.compactMap { $0.load() }
await withTaskGroup(of: Self.self) { taskGroup in
await withTaskGroup { taskGroup in
for generator in generators {
taskGroup.addTask { await generator.rawValue() }
}
Expand Down
50 changes: 25 additions & 25 deletions Sources/Testing/Test+Macro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ public macro Test<C>(
/// During testing, the associated test function is called once for each element
/// in `collection`.
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
///
/// ## See Also
///
/// - <doc:DefiningTests>
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
@attached(peer) public macro Test<C>(
_ displayName: _const String? = nil,
_ traits: any TestTrait...,
Expand Down Expand Up @@ -273,14 +273,14 @@ extension Test {
/// During testing, the associated test function is called once for each pair of
/// elements in `collection1` and `collection2`.
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
///
/// ## See Also
///
/// - <doc:DefiningTests>
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
@attached(peer)
@_documentation(visibility: private)
public macro Test<C1, C2>(
Expand All @@ -301,14 +301,14 @@ public macro Test<C1, C2>(
/// During testing, the associated test function is called once for each pair of
/// elements in `collection1` and `collection2`.
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
///
/// ## See Also
///
/// - <doc:DefiningTests>
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
@attached(peer) public macro Test<C1, C2>(
_ displayName: _const String? = nil,
_ traits: any TestTrait...,
Expand All @@ -327,14 +327,14 @@ public macro Test<C1, C2>(
/// During testing, the associated test function is called once for each element
/// in `zippedCollections`.
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
///
/// ## See Also
///
/// - <doc:DefiningTests>
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
@attached(peer)
@_documentation(visibility: private)
public macro Test<C1, C2>(
Expand All @@ -355,14 +355,14 @@ public macro Test<C1, C2>(
/// During testing, the associated test function is called once for each element
/// in `zippedCollections`.
///
/// @Comment {
/// - Bug: The testing library should support variadic generics.
/// ([103416861](rdar://103416861))
/// }
///
/// ## See Also
///
/// - <doc:DefiningTests>
//
// @Comment {
// - Bug: The testing library should support variadic generics.
// ([103416861](rdar://103416861))
// }
@attached(peer) public macro Test<C1, C2>(
_ displayName: _const String? = nil,
_ traits: any TestTrait...,
Expand Down
24 changes: 12 additions & 12 deletions Sources/Testing/Traits/ConditionTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ extension Trait where Self == ConditionTrait {
///
/// - Returns: An instance of ``ConditionTrait`` that evaluates the
/// closure you provide.
//
// @Comment {
// - Bug: `condition` cannot be `async` without making this function
// `async` even though `condition` is not evaluated locally.
// ([103037177](rdar://103037177))
// }
///
/// @Comment {
/// - Bug: `condition` cannot be `async` without making this function
/// `async` even though `condition` is not evaluated locally.
/// ([103037177](rdar://103037177))
/// }
public static func enabled(
if condition: @autoclosure @escaping @Sendable () throws -> Bool,
_ comment: Comment? = nil,
Expand Down Expand Up @@ -174,12 +174,12 @@ extension Trait where Self == ConditionTrait {
///
/// - Returns: An instance of ``ConditionTrait`` that evaluates the
/// closure you provide.
//
// @Comment {
// - Bug: `condition` cannot be `async` without making this function
// `async` even though `condition` is not evaluated locally.
// ([103037177](rdar://103037177))
// }
///
/// @Comment {
/// - Bug: `condition` cannot be `async` without making this function
/// `async` even though `condition` is not evaluated locally.
/// ([103037177](rdar://103037177))
/// }
public static func disabled(
if condition: @autoclosure @escaping @Sendable () throws -> Bool,
_ comment: Comment? = nil,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/Traits/TimeLimitTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func withTimeLimit(
_ body: @escaping @Sendable () async throws -> Void,
timeoutHandler: @escaping @Sendable () -> Void
) async throws {
try await withThrowingTaskGroup(of: Void.self) { group in
try await withThrowingTaskGroup { group in
group.addTask {
// If sleep() returns instead of throwing a CancellationError, that means
// the timeout was reached before this task could be cancelled, so call
Expand Down
4 changes: 4 additions & 0 deletions Tests/TestingTests/ConfirmationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

@testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing

#if canImport(Foundation)
private import Foundation
#endif

@Suite("Confirmation Tests")
struct ConfirmationTests {
@Test("Successful confirmations")
Expand Down
4 changes: 4 additions & 0 deletions Tests/TestingTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
@_spi(Experimental) @_spi(ForToolsIntegrationOnly) import _TestDiscovery
private import _TestingInternals

#if canImport(Foundation)
private import Foundation
#endif

@Test(/* name unspecified */ .hidden)
@Sendable func freeSyncFunction() {}
@Sendable func freeAsyncFunction() async {}
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestingTests/Support/CartesianProductTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct CartesianProductTests {
// Test that the product can be iterated multiple times concurrently.
let (_, _, product) = computeCartesianProduct()
let expectedSum = product.reduce(into: 0) { $0 &+= $1.1 }
await withTaskGroup(of: Int.self) { taskGroup in
await withTaskGroup { taskGroup in
for _ in 0 ..< 10 {
taskGroup.addTask {
product.reduce(into: 0) { $0 &+= $1.1 }
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestingTests/Support/LockTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct LockTests {
@Test("No lock")
func noLock() async {
let lock = LockedWith<Never, Int>(rawValue: 0)
await withTaskGroup(of: Void.self) { taskGroup in
await withTaskGroup { taskGroup in
for _ in 0 ..< 100_000 {
taskGroup.addTask {
lock.increment()
Expand Down
Loading