Skip to content

Commit 8ec0d06

Browse files
committed
Support for more flexible testing workflows with Revise.jl
1 parent 61dcd67 commit 8ec0d06

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

test/runtests.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ function eval_for_revise(str, path=tempname(), init=true)
4848
println(file, str)
4949
end
5050

51+
# In order to support different test workflows, we use `@__MODULE__` instead of `Main`
52+
# This way, we can `include("./runtests.jl")` from any module.
53+
mod = @__MODULE__
5154
if init
52-
Revise.includet(path)
55+
# Equivalent to `Revise.includet(path)`
56+
Revise.track(mod, path; mode=:includet)
5357
else
54-
main_pkg_data = Revise.pkgdatas[Base.PkgId(nothing, "Main")]
55-
Revise.revise_file_now(main_pkg_data, path)
58+
# Replicate the behavior of `Revise.track` when a file is changed
59+
pkg_id = Base.moduleroot(mod) == Main ? Base.PkgId(mod, string(mod)) : Base.PkgId(mod)
60+
pkg_data = Revise.pkgdatas[pkg_id]
61+
Revise.revise_file_now(pkg_data, path)
5662
end
5763

5864
return path

0 commit comments

Comments
 (0)