From b82cd9382ad64ed4fe484fc422440f1ff17bfc08 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 30 Dec 2023 09:57:51 -0600 Subject: [PATCH] Update tests for new parser errors --- test/common.jl | 3 +++ test/populate_compiled.jl | 4 ++-- test/runtests.jl | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/common.jl b/test/common.jl index ad6cef35..262642cb 100644 --- a/test/common.jl +++ b/test/common.jl @@ -91,3 +91,6 @@ if !isempty(ARGS) && "REVISE_TESTS_WATCH_FILES" ∈ ARGS idx = findall(isequal("REVISE_TESTS_WATCH_FILES"), ARGS) deleteat!(ARGS, idx) end + +errmsg(err::Base.Meta.ParseError) = err.msg +errmsg(err::AbstractString) = err diff --git a/test/populate_compiled.jl b/test/populate_compiled.jl index 1f3484ab..b074a8a9 100644 --- a/test/populate_compiled.jl +++ b/test/populate_compiled.jl @@ -1,4 +1,4 @@ -# This runs only on Travis. The goal is to populate the `.julia/compiled/v*` directory +# This runs only on CI. The goal is to populate the `.julia/compiled/v*` directory # with some additional files, so that `filter_valid_cachefiles` has to run. # This is to catch problems like #460. @@ -12,5 +12,5 @@ paths = Base.find_all_in_cache_path(id) Pkg.rm("EponymTuples") # we don't need it anymore path = first(paths) base, ext = splitext(path) -mv(path, base*"blahblah"*ext) +mv(path, base*"blahblah"*ext; force=true) Pkg.add(PackageSpec(name="EponymTuples")) diff --git a/test/runtests.jl b/test/runtests.jl index 27627fcd..0e507117 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -142,7 +142,7 @@ const issue639report = [] catch err @test isa(err, LoadError) @test err.file == file - @test endswith(err.error, "requires end") + @test endswith(errmsg(err.error), Base.VERSION < v"1.10" ? "requires end" : "Expected `end`") end end @@ -1979,7 +1979,7 @@ const issue639report = [] if ErrorType === LoadError @test exc.file == fn @test exc.line == line - @test occursin(msg, exc.error) + @test occursin(msg, errmsg(exc.error)) elseif ErrorType === UndefVarError @test msg == exc.var end @@ -1987,7 +1987,7 @@ const issue639report = [] end # test errors are reported the the first time - check_revision_error(logs[1], LoadError, "missing comma or }", 2) + check_revision_error(logs[1], LoadError, Base.VERSION < v"1.10" ? "missing comma or }" : "Expected `}`", 2 + (Base.VERSION >= v"1.10")) # Check that there's an informative warning rec = logs[2] @test startswith(rec.message, "The running code does not match") @@ -2003,7 +2003,7 @@ const issue639report = [] logs,_ = Test.collect_test_logs() do Revise.errors() end - check_revision_error(logs[1], LoadError, "missing comma or }", 2) + check_revision_error(logs[1], LoadError, Base.VERSION < v"1.10" ? "missing comma or }" : "Expected `}`", 2 + (Base.VERSION >= v"1.10")) write(joinpath(dn, "RevisionErrors.jl"), """ module RevisionErrors @@ -2033,7 +2033,8 @@ const issue639report = [] logs, _ = Test.collect_test_logs() do yry() end - check_revision_error(logs[1], LoadError, "unexpected \"=\"", 6) + delim = Base.VERSION < v"1.10" ? '"' : '`' + check_revision_error(logs[1], LoadError, "unexpected $delim=$delim", 6 + (Base.VERSION >= v"1.10")*2) write(joinpath(dn, "RevisionErrors.jl"), """ module RevisionErrors @@ -2079,7 +2080,7 @@ const issue639report = [] revise(throw=true) false catch err - isa(err, LoadError) && occursin("""unexpected "}" """, err.error) + isa(err, LoadError) && occursin(Base.VERSION < v"1.10" ? """unexpected "}" """ : "Expected `)`", errmsg(err.error)) end sleep(mtimedelay) write(joinpath(dn, "RevisionErrors.jl"), """