Skip to content

Handle Julia 1.14's syntax-versioned module expression in @testsetup - #246

Open
PingoLee wants to merge 1 commit into
JuliaTesting:mainfrom
PingoLee:fix-testsetup-versioned-module-expr
Open

PingoLee wants to merge 1 commit into
JuliaTesting:mainfrom
PingoLee:fix-testsetup-versioned-module-expr

Conversation

@PingoLee

@PingoLee PingoLee commented Oct 3, 2026

Copy link
Copy Markdown

Fixes #245.

On Julia 1.14 the module expression a macro receives can carry a leading syntax version,
Expr(:module, v"1.14.0", true, :Name, body) (JuliaLang/julia#60018), and @testsetup's
positional _, name, code = mod.args then binds name = true.

  • src/macros.jl: read name and body from the end of mod.args, which is correct for both the
    3-argument and the 4-argument form.
  • src/ReTestItems.jl: set the evaluated setup module's body with args[end] instead of
    args[3]. That isn't broken today, because the quoted :(module … end) is parsed under this
    package's own julia = "1.8" syntax version, but it has the same positional assumption and would
    silently 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 every
    CI version rather than only on 1.14+.
  • Version bump to 1.35.4.

Tested:

  • test/macros.jl: the new test errors with "@testsetup module expects a valid module name"
    without the src/ change and passes with it, on 1.12.7 and 1.14.0-DEV.3477.
  • Full Pkg.test(): 2039 pass / 3 broken on 1.12.7, and 1983 pass / 3 broken on
    1.14.0-DEV.3477 (the JUnit reference tests are skipped on prereleases, as runtests.jl intends).
    Under 1.14, Pkg.test's sandbox parses with the 1.14 syntax version, so unpatched test/macros.jl
    cannot even be lowered there.
  • Downstream: a package whose suite uses @testsetup collects and runs on 1.14.0-DEV.3477 with
    this branch. Without it, collection fails at the first @testsetup.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@testsetup fails on Julia 1.14: module expressions now carry a leading syntax version

1 participant