Skip to content

Commit dfc7c7b

Browse files
committed
Port SwiftPMBuildSystemTests to Swift Testing
1 parent 6abdf7b commit dfc7c7b

File tree

2 files changed

+178
-135
lines changed

2 files changed

+178
-135
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
public import Testing
14+
15+
public func expectThrowsError<T>(
16+
_ expression: @autoclosure () async throws -> T,
17+
_ message: @autoclosure () -> String = "",
18+
sourceLocation: SourceLocation = #_sourceLocation,
19+
errorHandler: (_ error: Error) -> Void = { _ in }
20+
) async {
21+
do {
22+
_ = try await expression()
23+
Issue.record("Expression was expected to throw but did not throw", sourceLocation: sourceLocation)
24+
} catch {
25+
errorHandler(error)
26+
}
27+
}

0 commit comments

Comments
 (0)