Skip to content

Commit fe8d3b4

Browse files
authored
increase coverage (#700)
1 parent d21eb50 commit fe8d3b4

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed

src/precompile.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# COV_EXCL_START
12
macro warnpcfail(ex::Expr)
23
modl = __module__
34
file = __source__.file === nothing ? "?" : String(__source__.file)
@@ -88,3 +89,4 @@ function _precompile_()
8889
end
8990
return nothing
9091
end
92+
# COV_EXCL_STOP

test/runtests.jl

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ const issue639report = []
9696
@test isequal(exs[2], Revise.RelocatableExpr(:(g(x) = sin(x))))
9797
@test !isequal(exs[1], Revise.RelocatableExpr(:(g(x) = sin(x))))
9898
@test string(rex) == """
99-
quote
100-
f(x) = begin
101-
x ^ 2
102-
end
103-
g(x) = begin
104-
sin(x)
105-
end
106-
end"""
99+
quote
100+
f(x) = begin
101+
x ^ 2
102+
end
103+
g(x) = begin
104+
sin(x)
105+
end
106+
end"""
107107
end
108108

109109
do_test("Equality and hashing") && @testset "Equality and hashing" begin
@@ -118,14 +118,14 @@ end"""
118118
do_test("Parse errors") && @testset "Parse errors" begin
119119
md = Revise.ModuleExprsSigs(Main)
120120
@test_throws LoadError Revise.parse_source!(md, """
121-
begin # this block should parse correctly, cf. issue #109
121+
begin # this block should parse correctly, cf. issue #109
122122
123-
end
124-
f(x) = 1
125-
g(x) = 2
126-
h{x) = 3 # error
127-
k(x) = 4
128-
""", "test", Main)
123+
end
124+
f(x) = 1
125+
g(x) = 2
126+
h{x) = 3 # error
127+
k(x) = 4
128+
""", "test", Main)
129129

130130
# Issue #448
131131
testdir = newtestdir()
@@ -312,6 +312,10 @@ k(x) = 4
312312
@test length(Revise.actions(rlogger)) == 6 # by default LineOffset is skipped
313313
@test length(Revise.actions(rlogger; line=true)) == 9
314314
@test_broken length(Revise.diffs(rlogger)) == 2
315+
io = PipeBuffer()
316+
foreach(rec -> show(io, rec), rlogger.logs)
317+
foreach(rec -> show(io, rec; verbose=false), rlogger.logs)
318+
@test count("Revise.LogRecord", read(io, String)) > 8
315319
empty!(rlogger.logs)
316320

317321
# Backtraces. Note this doesn't test the line-number correction
@@ -362,6 +366,11 @@ k(x) = 4
362366
rex3 = Revise.RelocatableExpr(:(x = $sym3))
363367
@test isequal(rex1, rex3)
364368
@test hash(rex1) == hash(rex3)
369+
370+
# coverage
371+
rex = convert(Revise.RelocatableExpr, :(a = 1))
372+
@test Revise.striplines!(rex) isa Revise.RelocatableExpr
373+
@test copy(rex) !== rex
365374
end
366375

367376
do_test("Display") && @testset "Display" begin
@@ -902,7 +911,7 @@ k(x) = 4
902911
""")
903912
sleep(mtimedelay)
904913
write(joinpath(dn, "file.jl"), "struct Ord2 end")
905-
@info "The following error messge is expected for this broken test"
914+
@info "The following error message is expected for this broken test"
906915
yry()
907916
@test_broken Order2.f(Order2.Ord2()) == 1
908917
# Resolve it with retry
@@ -3574,6 +3583,20 @@ do_test("includet with mod arg (issue #689)") && @testset "includet with mod arg
35743583
@test Driver.Codes.Common.foo == 2
35753584
end
35763585

3586+
do_test("misc - coverage") && @testset "misc - coverage" begin
3587+
@test Revise.ReviseEvalException("undef", UndefVarError(:foo)).loc isa String
3588+
@test !Revise.throwto_repl(UndefVarError(:foo))
3589+
3590+
@test endswith(Revise.fallback_juliadir(), "julia")
3591+
3592+
@test isnothing(Revise.revise(REPL.REPLBackend()))
3593+
end
3594+
3595+
do_test("deprecated") && @testset "deprecated" begin
3596+
@test_logs (:warn, r"`steal_repl_backend` has been removed.*") Revise.async_steal_repl_backend()
3597+
@test_logs (:warn, r"`steal_repl_backend` has been removed.*") Revise.wait_steal_repl_backend()
3598+
end
3599+
35773600
println("beginning cleanup")
35783601
GC.gc(); GC.gc()
35793602

@@ -3605,7 +3628,6 @@ GC.gc(); GC.gc(); GC.gc() # work-around for https://github.com/JuliaLang/julia
36053628

36063629
# see #532 Fix InitError opening none existent Project.toml
36073630
function load_in_empty_project_test()
3608-
36093631
# This will try to load Revise in a julia seccion
36103632
# with an empty enviroment (missing Project.toml)
36113633

@@ -3614,20 +3636,20 @@ function load_in_empty_project_test()
36143636
@assert isfile(revise_proj)
36153637

36163638
src = """
3617-
import Pkg
3618-
Pkg.activate("fake_env")
3619-
@assert !isfile(Base.active_project())
3639+
import Pkg
3640+
Pkg.activate("fake_env")
3641+
@assert !isfile(Base.active_project())
36203642
3621-
# force to load the package env Revise version
3622-
empty!(LOAD_PATH)
3623-
push!(LOAD_PATH, "$revise_proj")
3643+
# force to load the package env Revise version
3644+
empty!(LOAD_PATH)
3645+
push!(LOAD_PATH, "$revise_proj")
36243646
3625-
@info "A warning about no Manifest.toml file found is expected"
3626-
try; using Revise
3627-
catch err
3628-
# just fail for this error (see #532)
3629-
err isa InitError && rethrow(err)
3630-
end
3647+
@info "A warning about no Manifest.toml file found is expected"
3648+
try; using Revise
3649+
catch err
3650+
# just fail for this error (see #532)
3651+
err isa InitError && rethrow(err)
3652+
end
36313653
"""
36323654
cmd = `$julia --project=@. -E $src`
36333655

@@ -3636,6 +3658,7 @@ function load_in_empty_project_test()
36363658
true
36373659
end
36383660
end
3661+
36393662
do_test("Import in empty enviroment (issue #532)") && @testset "Import in empty enviroment (issue #532)" begin
36403663
load_in_empty_project_test();
36413664
end

0 commit comments

Comments
 (0)