Skip to content

Commit 50cb309

Browse files
committed
run swift-format
1 parent d9783d0 commit 50cb309

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,53 @@
1414
* limitations under the License.
1515
*/
1616
#if compiler(>=5.5)
17-
import XCTest
17+
import XCTest
1818

19-
extension XCTestCase {
20-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
21-
/// Cross-platform XCTest support for async-await tests.
22-
///
23-
/// Currently the Linux implementation of XCTest doesn't have async-await support.
24-
/// Until it does, we make use of this shim which uses a detached `Task` along with
25-
/// `XCTest.wait(for:timeout:)` to wrap the operation.
26-
///
27-
/// - NOTE: Support for Linux is tracked by https://bugs.swift.org/browse/SR-14403.
28-
/// - NOTE: Implementation currently in progress: https://github.com/apple/swift-corelibs-xctest/pull/326
29-
func XCTAsyncTest(
30-
expectationDescription: String = "Async operation",
31-
timeout: TimeInterval = 30,
32-
file: StaticString = #filePath,
33-
line: UInt = #line,
34-
function: StaticString = #function,
35-
operation: @escaping () async throws -> Void
36-
) {
37-
let expectation = self.expectation(description: expectationDescription)
38-
Task {
39-
do {
40-
try await operation()
41-
} catch {
42-
XCTFail("Error thrown while executing \(function): \(error)", file: file, line: line)
43-
Thread.callStackSymbols.forEach { print($0) }
44-
}
45-
expectation.fulfill()
19+
extension XCTestCase {
20+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
21+
/// Cross-platform XCTest support for async-await tests.
22+
///
23+
/// Currently the Linux implementation of XCTest doesn't have async-await support.
24+
/// Until it does, we make use of this shim which uses a detached `Task` along with
25+
/// `XCTest.wait(for:timeout:)` to wrap the operation.
26+
///
27+
/// - NOTE: Support for Linux is tracked by https://bugs.swift.org/browse/SR-14403.
28+
/// - NOTE: Implementation currently in progress: https://github.com/apple/swift-corelibs-xctest/pull/326
29+
func XCTAsyncTest(
30+
expectationDescription: String = "Async operation",
31+
timeout: TimeInterval = 30,
32+
file: StaticString = #filePath,
33+
line: UInt = #line,
34+
function: StaticString = #function,
35+
operation: @escaping () async throws -> Void
36+
) {
37+
let expectation = self.expectation(description: expectationDescription)
38+
Task {
39+
do {
40+
try await operation()
41+
} catch {
42+
XCTFail("Error thrown while executing \(function): \(error)", file: file, line: line)
43+
Thread.callStackSymbols.forEach { print($0) }
44+
}
45+
expectation.fulfill()
46+
}
47+
self.wait(for: [expectation], timeout: timeout)
48+
}
4649
}
47-
self.wait(for: [expectation], timeout: timeout)
48-
}
49-
}
5050

51-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
52-
internal func XCTAssertThrowsError<T>(
53-
_ expression: @autoclosure () async throws -> T,
54-
verify: (Error) -> Void = { _ in },
55-
file: StaticString = #file,
56-
line: UInt = #line
57-
) async {
58-
do {
59-
_ = try await expression()
60-
XCTFail("Expression did not throw error", file: file, line: line)
61-
} catch {
62-
verify(error)
63-
}
64-
}
51+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
52+
internal func XCTAssertThrowsError<T>(
53+
_ expression: @autoclosure () async throws -> T,
54+
verify: (Error) -> Void = { _ in },
55+
file: StaticString = #file,
56+
line: UInt = #line
57+
) async {
58+
do {
59+
_ = try await expression()
60+
XCTFail("Expression did not throw error", file: file, line: line)
61+
} catch {
62+
verify(error)
63+
}
64+
}
6565

6666
#endif // compiler(>=5.5)

0 commit comments

Comments
 (0)