You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for creating this library! It fills a sorely-needed gap in the new compiler macro feature.
I'm writing BDD tests using the Quick framework. When recording a new assertion, I see the following result:
import MacroTesting
import Quick
@testable import MyMacroImplementation
class MacroSpec: QuickSpec {
override func invokeTest() {
withMacroTesting(macros: ["MyMacro": MyMacro.self]) {
super.invokeTest()
}
}
override class func spec() {
describe("the @MyMacro macro") {
it("should fail when annotating a non-class type") {
assertMacro {
"""
@MyMacro()
struct S {}
"""
} diagnostics: {
"""
@MyMacro()
╰─ 🛑 'MyMacro' macro can only be applied to a class
struct S {}
"""
}
}
}
}
}
Beyond just the initial formatting (non-indented), this generated expansion will fail because of the newlines between each generated statement. This example demonstrates a generated diagnostic message, but I've also observed this for the "expansion" argument as well.
Checklist
If possible, I've reproduced the issue using the main branch of this package.
@tylervick Can you share a project that reproduces the problem? We're using MacroTesting a bunch and haven't encountered the issue, but we're also not Quick users. If you can share a project using Quick that exhibits the problem that would help us diagnose the issue and determine if it's a bug in our library, or somehow in Quick.
I was able to reproduce this issue. It is a bug in how indentation was being calculated when rewriting the test source file. A PR with the fix has been submitted.
@tylervick You can take a look at the PR referenced above for details. But the quick fix is to simply delete the empty line between the class MacroSpec declaration and the invokeTest function declaration. Or make sure there are no leading spaces in that empty line.
Description
Thank you for creating this library! It fills a sorely-needed gap in the new compiler macro feature.
I'm writing BDD tests using the Quick framework. When recording a new assertion, I see the following result:
Beyond just the initial formatting (non-indented), this generated expansion will fail because of the newlines between each generated statement. This example demonstrates a generated diagnostic message, but I've also observed this for the "expansion" argument as well.
Checklist
main
branch of this package.Expected behavior
Given the above example, the generated diagnostic string should look like the following (indentation omitted):
Actual behavior
The generated string contains superfluous newlines:
Steps to reproduce
assertMacro
to test the given macro, only populate the first closureswift-macro-testing version information
0.2.1
Destination operating system
macOS 13
Xcode version information
15.0 (15A240d)
Swift Compiler version information
The text was updated successfully, but these errors were encountered: