File tree Expand file tree Collapse file tree 3 files changed +185
-135
lines changed
Tests/BuildSystemIntegrationTests Expand file tree Collapse file tree 3 files changed +185
-135
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -14,12 +14,19 @@ import Foundation
14
14
package import SourceKitD
15
15
import ToolchainRegistry
16
16
17
+ // Anchor class to lookup the testing bundle when swiftpm-testing-helper is used.
18
+ private final class TestingAnchor { }
19
+
17
20
/// The path to the `SwiftSourceKitPluginTests` test bundle. This gives us a hook into the the build directory.
18
21
private let xctestBundle : URL = {
19
22
#if canImport(Darwin)
20
23
for bundle in Bundle . allBundles where bundle. bundlePath. hasSuffix ( " .xctest " ) {
21
24
return bundle. bundleURL
22
25
}
26
+ let bundle = Bundle ( for: TestingAnchor . self)
27
+ if bundle. bundlePath. hasSuffix ( " .xctest " ) {
28
+ return bundle. bundleURL
29
+ }
23
30
preconditionFailure ( " Failed to find xctest bundle " )
24
31
#else
25
32
return URL (
You can’t perform that action at this time.
0 commit comments