Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

booktests: some future-proofing #4172

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading