Skip to content

Commit

Permalink
expand tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Nov 14, 2023
1 parent 418af2d commit 438bb20
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,47 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test occursin(expected, got) || (expected, got)
@test_broken occursin(expected_good, got)

# Ask for coverage in current directory
tdir = dirname(realpath(inputfile))
cd(tdir) do
# there may be atrailing separator here so use rstrip
@test readchomp(`$exename -E "(Base.JLOptions().code_coverage, rstrip(unsafe_string(Base.JLOptions().tracked_path), '/'))" -L $inputfile
--code-coverage=$covfile --code-coverage=@`) == "(3, $(repr(tdir)))"
end
@test isfile(covfile)
got = read(covfile, String)
rm(covfile)
@test occursin(expected, got) || (expected, got)
@test_broken occursin(expected_good, got)

# Ask for coverage in relative directory
tdir = dirname(realpath(inputfile))
cd(dirname(tdir)) do
@test readchomp(`$exename -E "(Base.JLOptions().code_coverage, unsafe_string(Base.JLOptions().tracked_path))" -L $inputfile
--code-coverage=$covfile --code-coverage=@testhelpers`) == "(3, $(repr(tdir)))"
end
@test isfile(covfile)
got = read(covfile, String)
rm(covfile)
@test occursin(expected, got) || (expected, got)
@test_broken occursin(expected_good, got)

# Ask for coverage in relative directory with dot-dot notation
tdir = dirname(realpath(inputfile))
cd(tdir) do
@test readchomp(`$exename -E "(Base.JLOptions().code_coverage, unsafe_string(Base.JLOptions().tracked_path))" -L $inputfile
--code-coverage=$covfile --code-coverage=@../testhelpers`) == "(3, $(repr(tdir)))"
end
@test isfile(covfile)
got = read(covfile, String)
rm(covfile)
@test occursin(expected, got) || (expected, got)
@test_broken occursin(expected_good, got)

# Ask for coverage in a different directory
tdir = mktempdir() # a dir that contains no code
@test readchomp(`$exename -E "(Base.JLOptions().code_coverage, unsafe_string(Base.JLOptions().tracked_path))" -L $inputfile
--code-coverage=$covfile --code-coverage=@$tdir`) == "(3, $(repr(tdir)))"
--code-coverage=$covfile --code-coverage=@$tdir`) == "(3, $(repr(realpath(tdir))))"
@test isfile(covfile)
got = read(covfile, String)
@test isempty(got)
Expand Down

0 comments on commit 438bb20

Please sign in to comment.