Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "juliadir" test
Browse files Browse the repository at this point in the history
The test was ineffective because it was relying on binding replacement,
which is undefined behavior on all versions of Julia (ironically it will
not be in 1.12, but that change is not done yet). As a result,
the redefinition of `juliadir` was not taking effect and the
test was simply running with the old juliadir. Change `juliadir`
to a (typed) global and update the test to make sure it's actually
working.
Keno committed Nov 18, 2024
1 parent ec869e7 commit 1c80fb8
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/packagedef.jl
Original file line number Diff line number Diff line change
@@ -178,13 +178,21 @@ function fallback_juliadir()
normpath(candidate)
end

if VERSION >= v"1.8"
Core.eval(@__MODULE__, :(global juliadir::String))
else
Core.eval(@__MODULE__, :(global juliadir #= ::Any =#; nothing))
end

"""
Revise.juliadir
Constant specifying full path to julia top-level source directory.
This should be reliable even for local builds, cross-builds, and binary installs.
"""
const juliadir = normpath(
juliadir

juliadir = normpath(
if isdir(joinpath(basebuilddir, "base"))
basebuilddir
else
9 changes: 5 additions & 4 deletions test/juliadir.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Revise, InteractiveUtils, Test

@eval Revise const juliadir = ARGS[1]
@eval Revise juliadir = ARGS[1]

@test Revise.juliadir != Revise.basebuilddir
@test Revise.juliadir != Revise.fallback_juliadir()

@show Revise.juliadir

# https://github.com/timholy/Revise.jl/issues/697
@test Revise.definition(@which(Float32(π))) isa Expr
let def = Revise.definition(@which(Float32(π)))
@test Meta.isexpr(def, :macrocall)
@test startswith(String(def.args[2].file), Revise.juliadir)
end

0 comments on commit 1c80fb8

Please sign in to comment.