Skip to content

Commit 71d8e61

Browse files
authored
Fix "juliadir" test (#867)
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.
1 parent ec869e7 commit 71d8e61

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/packagedef.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,21 @@ function fallback_juliadir()
178178
normpath(candidate)
179179
end
180180

181+
if VERSION >= v"1.8"
182+
Core.eval(@__MODULE__, :(global juliadir::String))
183+
else
184+
Core.eval(@__MODULE__, :(global juliadir #= ::Any =#; nothing))
185+
end
186+
181187
"""
182188
Revise.juliadir
183189
184190
Constant specifying full path to julia top-level source directory.
185191
This should be reliable even for local builds, cross-builds, and binary installs.
186192
"""
187-
const juliadir = normpath(
193+
juliadir
194+
195+
juliadir = normpath(
188196
if isdir(joinpath(basebuilddir, "base"))
189197
basebuilddir
190198
else

test/juliadir.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using Revise, InteractiveUtils, Test
22

3-
@eval Revise const juliadir = ARGS[1]
3+
@eval Revise juliadir = ARGS[1]
44

55
@test Revise.juliadir != Revise.basebuilddir
66
@test Revise.juliadir != Revise.fallback_juliadir()
77

8-
@show Revise.juliadir
9-
108
# https://github.com/timholy/Revise.jl/issues/697
11-
@test Revise.definition(@which(Float32(π))) isa Expr
9+
let def = Revise.definition(@which(Float32(π)))
10+
@test isa(def, Expr)
11+
@test Meta.isexpr(def, :macrocall)
12+
end

0 commit comments

Comments
 (0)