-
Notifications
You must be signed in to change notification settings - Fork 440
Implement a version of SwiftSyntaxMacrosTestsSupport
that is framework agnostic
#2647
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
Conversation
…n Foundation or XCTest This allows us to use these functions from a framework-agnostic `SwiftSyntaxMacroTestSupport` module. All changes are in underscored modules and thus don’t have any API impact.
@swift-ci Please test |
Happy to help—can you clarify what you need from me? |
fe0773e
to
2b3d748
Compare
It would be good to get some confirmation that this change actually allows writing tests for macros using swift-testing. |
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Looks like it ought to work, although I noticed it seems a bit picky about whitespace not matching. I'm getting this warning:
I don't think this is a great interface (this is partially copied from my previous PR, I assume?) but short of adding macro-aware overloads of |
…CTest or Foundation rdar://119519713
…tSupportFrameworkAgnostic`
dc4c0ab
to
beb322f
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
} | ||
|
||
/// Defines the details of a test failure, consisting of a message and the location at which the l | ||
public struct TestFailureSpec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you consider throwing this as an Error
and catch let error as TestFailureSpec {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that we could only throw a single failure and not multiple.
Sources/_SwiftSyntaxTestSupportFrameworkAgnostic/String+TrimmingTrailingWhitespace.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxMacrosTestSupportFrameworkAgnostic/Assertions.swift
Outdated
Show resolved
Hide resolved
Sources/_SwiftSyntaxTestSupportFrameworkAgnostic/AssertEqualWithDiff.swift
Outdated
Show resolved
Hide resolved
Note to self: A suggestion for the module name |
If we eventually wanted to make it a cross-module overlay, I think the idiomatic name would be |
Instead, expose `String` and `Int` variants publicly that can be passed directly in to `Issue.record` from `swift-testing`.
1715ac7
to
537e1a2
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
@swift-ci Please test |
@swift-ci Please test Windows |
/// Defines the location at which the a test failure should be anchored. This is typically the location where the | ||
/// assertion function is called. | ||
public struct TestFailureLocation { | ||
@_spi(XCTestFailureLocation) public let staticFileID: StaticString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you purposefully not updating the SPI name, or is it just a left over from the move?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These symbols are only used when using the existing XCTest-based functions, and are used internally in those functions. The ones used by a caller using swift-testing use the normalized types (String
and Int
) instead of the types used by XCTFail()
(StaticString
and UInt
.) This was an intentional decision. :)
SwiftSyntaxMacrosTestsSupport
does not depend onXCTest
orFoundation
can be used to write macro tests usingswift-testing
.I am not quite happy with the name
SwiftSyntaxMacrosTestsSupportFrameworkAgnostic
yet but haven’t come up with one that’s significantly better. I’m open to suggestions.rdar://119519713
@grynspan Could you check if
SwiftSyntaxMacrosTestsSupportFrameworkAgnostic
works to write macro tests usingswift-testing
?