-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt Swift-Testing in test utils such as SwiftSyntaxMacrosTestSupport
#2720
Comments
Not that hard to do, even manually.
[Update]: added some more imports to the code. |
Synced to Apple’s issue tracker as rdar://131312113 |
SwiftSyntaxMacrosTestSupport
SwiftSyntaxMacrosTestSupport
FWIW rather than |
swift-testing is not supported for macro expansion tests yet. See swiftlang/swift-syntax#2720
@ahoppen we're moving our tests away from I might be able to get away with putting some things together for our specific project in that repo itself, but in terms of swift-testing support in SwiftSyntax, what do think is needed to be done, generally? Just want to make sure I have a somewhat accurate idea about what this issue requires. |
@ahoppen I noticed this:
More specifically:
I assume it's no longer true considering swift-testing has made its way to the toolchains? |
The circular dependency still exists. |
@grynspan Then how come my branch right here builds and runs swift-testing tests just fine both on macOS and Try it yourself: docker run --rm -it swift:6.0-jammy bash -c "git clone https://github.com/MahdiBM/swift-syntax.git && cd swift-syntax && git checkout mmbm-swift-testing-macros-test-support && swift build --build-tests && swift test --filter SwiftSyntaxMacrosTestingTests" result: Cloning into 'swift-syntax'...
remote: Enumerating objects: 57916, done.
remote: Counting objects: 100% (3116/3116), done.
remote: Compressing objects: 100% (1099/1099), done.
remote: Total 57916 (delta 2346), reused 2494 (delta 1997), pack-reused 54800 (from 1)
Receiving objects: 100% (57916/57916), 25.91 MiB | 3.27 MiB/s, done.
Resolving deltas: 100% (45856/45856), done.
Branch 'mmbm-swift-testing-macros-test-support' set up to track remote branch 'mmbm-swift-testing-macros-test-support' from 'origin'.
Switched to a new branch 'mmbm-swift-testing-macros-test-support'
warning: 'swift-syntax': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
/swift-syntax/Sources/SwiftLexicalLookup/CMakeLists.txt
Building for debugging...
[726/726] Linking swift-syntaxPackageTests.xctest
Build complete! (38.88s)
warning: 'swift-syntax': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
/swift-syntax/Sources/SwiftLexicalLookup/CMakeLists.txt
Building for debugging...
[1/1] Write swift-version-24593BA9C3E375BF.txt
Build complete! (0.32s)
Test Suite 'Selected tests' started at 2024-11-21 14:29:55.739
Test Suite 'Selected tests' passed at 2024-11-21 14:29:55.741
Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
◇ Test run started.
↳ Testing Library Version: 6.0.1 (324940967b09dbb)
◇ Suite AssertionsTests started.
◇ Test assertMacroExpansionMatchesSingleStringHighlight() started.
◇ Test assertMacroExpansionIgnoresHighlightMatchingIfNil() started.
◇ Test assertMacroExpansionMatchesArrayHighlight() started.
✔ Test assertMacroExpansionMatchesSingleStringHighlight() passed after 0.005 seconds.
✔ Test assertMacroExpansionIgnoresHighlightMatchingIfNil() passed after 0.005 seconds.
✔ Test assertMacroExpansionMatchesArrayHighlight() passed after 0.005 seconds.
✔ Suite AssertionsTests passed after 0.005 seconds.
✔ Test run with 3 tests passed after 0.005 seconds. |
Now build the toolchain from source. :) |
@grynspan I see, but is that a blocking matter? cc @ahoppen |
It would prevent using Swift Testing as a package. Although Swift Testing is in the toolchain today, the core team is interested in moving it to a package in the future, and that would not be possible if it created a circular dependency at package resolution time. |
Description
Currently you need to use
XCTest
to run macro tests withSwiftSyntaxMacrosTestSupport
functions because they rely on someXCTest
functions such asXCTFail
.swift-syntax tests utils should also support Swift-Testing.
The text was updated successfully, but these errors were encountered: