Skip to content

Commit acc70ad

Browse files
authored
Merge pull request #2655 from ahoppen/6.0/framework-agnostic-tests
[6.0] Implement a version of `SwiftSyntaxMacrosTestsSupport` that is framework agnostic
2 parents 81a50c9 + d967e4a commit acc70ad

File tree

9 files changed

+837
-543
lines changed

9 files changed

+837
-543
lines changed

Package.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ let package = Package(
2727
.library(name: "SwiftSyntaxMacros", targets: ["SwiftSyntaxMacros"]),
2828
.library(name: "SwiftSyntaxMacroExpansion", targets: ["SwiftSyntaxMacroExpansion"]),
2929
.library(name: "SwiftSyntaxMacrosTestSupport", targets: ["SwiftSyntaxMacrosTestSupport"]),
30+
.library(
31+
name: "SwiftSyntaxMacrosGenericTestSupport",
32+
targets: ["SwiftSyntaxMacrosGenericTestSupport"]
33+
),
3034
],
3135
targets: [
3236
// MARK: - Internal helper targets
@@ -40,7 +44,18 @@ let package = Package(
4044

4145
.target(
4246
name: "_SwiftSyntaxTestSupport",
43-
dependencies: ["SwiftBasicFormat", "SwiftSyntax", "SwiftSyntaxBuilder", "SwiftSyntaxMacroExpansion"]
47+
dependencies: [
48+
"_SwiftSyntaxGenericTestSupport",
49+
"SwiftBasicFormat",
50+
"SwiftSyntax",
51+
"SwiftSyntaxBuilder",
52+
"SwiftSyntaxMacroExpansion",
53+
]
54+
),
55+
56+
.target(
57+
name: "_SwiftSyntaxGenericTestSupport",
58+
dependencies: []
4459
),
4560

4661
.testTarget(
@@ -207,7 +222,19 @@ let package = Package(
207222
.target(
208223
name: "SwiftSyntaxMacrosTestSupport",
209224
dependencies: [
210-
"_SwiftSyntaxTestSupport",
225+
"SwiftSyntax",
226+
"SwiftSyntaxMacroExpansion",
227+
"SwiftSyntaxMacros",
228+
"SwiftSyntaxMacrosGenericTestSupport",
229+
]
230+
),
231+
232+
// MARK: SwiftSyntaxMacrosGenericTestSupport
233+
234+
.target(
235+
name: "SwiftSyntaxMacrosGenericTestSupport",
236+
dependencies: [
237+
"_SwiftSyntaxGenericTestSupport",
211238
"SwiftDiagnostics",
212239
"SwiftIDEUtils",
213240
"SwiftParser",

Release Notes/600.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
- Description: `SyntaxIdentifier.indexInTree` allows the retrieval of a `SyntaxIdentifier` that identifies the syntax node independent of the syntax tree. `SyntaxIdentifier.fromIndexInTree` allows the creation for a `SyntaxIdentifier` from a tree-agnostic `SyntaxIdentifier.IndexInTree` and the tree's root node.
9292
- Pull request: https://github.com/apple/swift-syntax/pull/2594
9393

94+
- `SwiftSyntaxMacrosGenericTestSupport`
95+
- Description: A version of the `SwiftSyntaxMacrosTestSupport` module that doesn't depend on `Foundation` or `XCTest` and can thus be used to write macro tests using `swift-testing`. Since swift-syntax can't depend on swift-testing (which would incur a circular dependency since swift-testing depends on swift-syntax), users need to manually specify a failure handler like the following, that fails the swift-testing test: `Issue.record("\($0.message)", fileID: $0.location.fileID, filePath: $0.location.filePath, line: $0.location.line, column: $0.location.column)`
96+
- Pull request: https://github.com/apple/swift-syntax/pull/2647
97+
9498
## API Behavior Changes
9599

96100
## Deprecations

0 commit comments

Comments
 (0)