Skip to content

Commit

Permalink
Allow paths for test(; coverage = ...). (#3178)
Browse files Browse the repository at this point in the history
Fixes #3177.

Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
  • Loading branch information
tpapp and KristofferC authored Sep 30, 2022
1 parent 3208522 commit da496b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1526,9 +1526,16 @@ function gen_test_code(source_path::String;
append!(empty!(ARGS), $(repr(test_args.exec)))
include($(repr(test_file)))
"""
coverage_arg = if coverage isa Bool
coverage ? string("@", source_path) : "none"
elseif coverage isa AbstractString
coverage
else
throw(ArgumentError("coverage should be a boolean or a string."))
end
return ```
$(Base.julia_cmd())
--code-coverage=$(coverage ? string("@", source_path) : "none")
--code-coverage=$(coverage_arg)
--color=$(Base.have_color === nothing ? "auto" : Base.have_color ? "yes" : "no")
--compiled-modules=$(Bool(Base.JLOptions().use_compiled_modules) ? "yes" : "no")
--check-bounds=yes
Expand Down
10 changes: 10 additions & 0 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ temp_pkg_dir() do project_path
Pkg.rm(TEST_PKG.name)
end

@testset "coverage specific path" begin
mktempdir() do tmp
coverage_path = joinpath(tmp, "tracefile.info")
Pkg.add(TEST_PKG.name)
Pkg.test(TEST_PKG.name; coverage = coverage_path)
@test isfile(coverage_path)
end
Pkg.rm(TEST_PKG.name)
end

@testset "pinning / freeing" begin
Pkg.add(TEST_PKG.name)
old_v = Pkg.dependencies()[TEST_PKG.uuid].version
Expand Down

0 comments on commit da496b8

Please sign in to comment.