Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow paths for test(; coverage = ...). #3178

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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