Skip to content

Commit 428ade7

Browse files
Merge pull request #7615 from tlycken/coverage-kwargs
Code coverage kwarg for Pkg.test
2 parents e6cb46b + 7f89508 commit 428ade7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

base/pkg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ generate(pkg::String, license::String; force::Bool=false) =
6363
cd(Generate.package,pkg,license,force=force)
6464

6565

66-
test() = cd(Entry.test)
67-
test(pkgs::String...) = cd(Entry.test,String[pkgs...])
66+
test(;coverage::Bool=false) = cd(Entry.test; coverage=coverage)
67+
test(pkgs::String...; coverage::Bool=false) = cd(Entry.test,String[pkgs...]; coverage=coverage)
6868

6969
@deprecate release free
7070
@deprecate fixup build

base/pkg/entry.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ function updatehook(pkgs::Vector)
666666
""")
667667
end
668668

669-
function test!(pkg::String, errs::Vector{String}, notests::Vector{String})
669+
function test!(pkg::String, errs::Vector{String}, notests::Vector{String}; coverage::Bool=false)
670670
const reqs_path = abspath(pkg,"test","REQUIRE")
671671
if isfile(reqs_path)
672672
const tests_require = Reqs.parse(reqs_path)
@@ -680,7 +680,12 @@ function test!(pkg::String, errs::Vector{String}, notests::Vector{String})
680680
info("Testing $pkg")
681681
cd(dirname(test_path)) do
682682
try
683-
run(`$JULIA_HOME/julia $test_path`)
683+
if coverage
684+
cmd = `$JULIA_HOME/julia --code-coverage $test_path`
685+
else
686+
cmd = `$JULIA_HOME/julia $test_path`
687+
end
688+
run(cmd)
684689
info("$pkg tests passed")
685690
catch err
686691
warnbanner(err, label="[ ERROR: $pkg ]")
@@ -693,11 +698,11 @@ function test!(pkg::String, errs::Vector{String}, notests::Vector{String})
693698
resolve()
694699
end
695700

696-
function test(pkgs::Vector{String})
701+
function test(pkgs::Vector{String}; coverage::Bool=false)
697702
errs = String[]
698703
notests = String[]
699704
for pkg in pkgs
700-
test!(pkg,errs,notests)
705+
test!(pkg,errs,notests; coverage=coverage)
701706
end
702707
if !isempty(errs) || !isempty(notests)
703708
messages = String[]
@@ -707,6 +712,6 @@ function test(pkgs::Vector{String})
707712
end
708713
end
709714

710-
test() = test(sort!(String[keys(installed())...]))
715+
test(;coverage::Bool=false) = test(sort!(String[keys(installed())...]); coverage=coverage)
711716

712717
end # module

0 commit comments

Comments
 (0)