Conversation
Under a 1.14 syntax version a macro receives `Expr(:module, v"1.14.0", true, :Name, body)` (JuliaLang/julia#60018), so the positional `_, name, code = mod.args` bound `name = true` and every `@testsetup` failed to expand. Read name and body from the end of `args`, which is correct for both forms. Do the same where the setup module is rebuilt for evaluation: it is parsed under this package's own syntax version today, so it is latent, not broken. Fixes JuliaTesting#245 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #245.
On Julia 1.14 the
moduleexpression a macro receives can carry a leading syntax version,Expr(:module, v"1.14.0", true, :Name, body)(JuliaLang/julia#60018), and@testsetup'spositional
_, name, code = mod.argsthen bindsname = true.src/macros.jl: readnameandbodyfrom the end ofmod.args, which is correct for both the3-argument and the 4-argument form.
src/ReTestItems.jl: set the evaluated setup module's body withargs[end]instead ofargs[3]. That isn't broken today, because the quoted:(module … end)is parsed under thispackage's own
julia = "1.8"syntax version, but it has the same positional assumption and wouldsilently overwrite the module name once that compat moves to 1.14.
test/macros.jl: a regression test that builds the 4-argument form directly, so it runs on everyCI version rather than only on 1.14+.
Tested:
test/macros.jl: the new test errors with "@testsetup moduleexpects a valid module name"without the
src/change and passes with it, on 1.12.7 and 1.14.0-DEV.3477.Pkg.test(): 2039 pass / 3 broken on 1.12.7, and 1983 pass / 3 broken on1.14.0-DEV.3477 (the JUnit reference tests are skipped on prereleases, as
runtests.jlintends).Under 1.14,
Pkg.test's sandbox parses with the 1.14 syntax version, so unpatchedtest/macros.jlcannot even be lowered there.
@testsetupcollects and runs on 1.14.0-DEV.3477 withthis branch. Without it, collection fails at the first
@testsetup.🤖 Generated with Claude Code