From 3c135b3d8a911c1bec7c5a03c9bdb6163ea89aaa Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Wed, 2 Oct 2024 09:39:05 +0200 Subject: [PATCH] booktests: some future-proofing --- .github/workflows/CI.yml | 3 +++ test/book/test.jl | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 49899424ae08..235eddb1dbe6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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' diff --git a/test/book/test.jl b/test/book/test.jl index e6f1cf018aad..faf9a1cb3a8a 100644 --- a/test/book/test.jl +++ b/test/book/test.jl @@ -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 => "\n") # this removes the package version slug, filename and linenumber @@ -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)))) @@ -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() @@ -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)