Skip to content

Commit 8a4d12e

Browse files
authored
Merge pull request #2647 from ahoppen/framework-agnostic-tests
Implement a version of `SwiftSyntaxMacrosTestsSupport` that is framework agnostic
2 parents 3f80354 + 769a78b commit 8a4d12e

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(
@@ -215,7 +230,19 @@ let package = Package(
215230
.target(
216231
name: "SwiftSyntaxMacrosTestSupport",
217232
dependencies: [
218-
"_SwiftSyntaxTestSupport",
233+
"SwiftSyntax",
234+
"SwiftSyntaxMacroExpansion",
235+
"SwiftSyntaxMacros",
236+
"SwiftSyntaxMacrosGenericTestSupport",
237+
]
238+
),
239+
240+
// MARK: SwiftSyntaxMacrosGenericTestSupport
241+
242+
.target(
243+
name: "SwiftSyntaxMacrosGenericTestSupport",
244+
dependencies: [
245+
"_SwiftSyntaxGenericTestSupport",
219246
"SwiftDiagnostics",
220247
"SwiftIDEUtils",
221248
"SwiftParser",

Release Notes/600.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
- Description: `Range<AbsolutePosition>` gained a few convenience functions inspired from `ByteSourceRange`: `init(position:length:)`, `length`, `overlapsOrTouches`
9696
- Pull request: https://github.com/apple/swift-syntax/pull/2587
9797

98+
- `SwiftSyntaxMacrosGenericTestSupport`
99+
- 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)`
100+
- Pull request: https://github.com/apple/swift-syntax/pull/2647
101+
98102
## API Behavior Changes
99103

100104
## Deprecations

0 commit comments

Comments
 (0)