Skip to content

Commit

Permalink
booktests: some future-proofing (#4172)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz authored Oct 2, 2024
1 parent f8edfcb commit ec05d52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
- julia-version: '1.10'
group: 'book'
os: ubuntu-latest
- julia-version: 'nightly'
group: 'book'
os: ubuntu-latest
# nightly on macos is disabled for now since the macos jobs take too long
# with just 5 runners
#- julia-version: 'nightly'
Expand Down
6 changes: 4 additions & 2 deletions test/book/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ isdefined(Main, :FakeTerminals) || include(joinpath(pkgdir(REPL),"test","FakeTer
result = strip(result)
result = replace(result, r"julia>$"s => "")
# canonicalize numbered anonymous functions
result = replace(result, r"^\s*(?:#\d+)?(.* \(generic function with ).*\n"m => s"\1\n")
result = replace(result, r"^\s*(?:#[a-z_]+#)?(?:#\d+)?(.* \(generic function with ).*\n"m => s"\1\n")
# remove timings
result = replace(result, r"^\s*[0-9\.]+ seconds \(.* allocations: .*\)$"m => "<timing>\n")
# this removes the package version slug, filename and linenumber
Expand Down Expand Up @@ -120,6 +120,7 @@ isdefined(Main, :FakeTerminals) || include(joinpath(pkgdir(REPL),"test","FakeTer
sym = Symbol("__", lstrip(string(gensym()), '#'))
mockdule = Module(sym)
# make it accessible from Main
@eval Main global $sym::Module
setproperty!(Main, sym, mockdule)
Core.eval(mockdule, :(eval(x) = Core.eval($(mockdule), x)))
Core.eval(mockdule, :(include(x) = Base.include($(mockdule), abspath(x))))
Expand Down Expand Up @@ -182,6 +183,7 @@ isdefined(Main, :FakeTerminals) || include(joinpath(pkgdir(REPL),"test","FakeTer
# add overlay project for plots
custom_load_path = []
old_load_path = []
oldrepl = isdefined(Base, :active_repl) ? Base.active_repl : nothing
copy!(custom_load_path, LOAD_PATH)
copy!(old_load_path, LOAD_PATH)
curdir = pwd()
Expand Down Expand Up @@ -268,7 +270,7 @@ isdefined(Main, :FakeTerminals) || include(joinpath(pkgdir(REPL),"test","FakeTer
end
finally
# restore some state
Main.REPL.activate(Main)
isnothing(oldrepl) || Main.REPL.activate(Main)
Pkg.activate("$act_proj"; io=devnull)
cd(curdir)
copy!(LOAD_PATH, old_load_path)
Expand Down

0 comments on commit ec05d52

Please sign in to comment.