Skip to content

Commit 7182688

Browse files
Pass coverage flag to worker process (#284)
1 parent 765f39c commit 7182688

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/server.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ function _exeflags_and_env(options)
140140
end
141141
# if exeflags already contains '--color=no', the 'no' will prevail
142142
pushfirst!(exeflags, "--color=yes")
143+
144+
# Ensure that coverage settings are passed to the worker so that worker
145+
# code is tracked correctly during tests.
146+
# Based on https://github.com/JuliaLang/julia/blob/eed18bdf706b7aab15b12f3ba0588e8fafcd4930/base/util.jl#L216-L229.
147+
opts = Base.JLOptions()
148+
if opts.code_coverage != 0
149+
# Forward the code-coverage flag only if applicable (if the filename
150+
# is pid-dependent)
151+
coverage_file =
152+
(opts.output_code_coverage != C_NULL) ?
153+
unsafe_string(opts.output_code_coverage) : ""
154+
if isempty(coverage_file) || occursin("%p", coverage_file)
155+
if opts.code_coverage == 1
156+
push!(exeflags, "--code-coverage=user")
157+
elseif opts.code_coverage == 2
158+
push!(exeflags, "--code-coverage=all")
159+
elseif opts.code_coverage == 3
160+
push!(exeflags, "--code-coverage=@$(unsafe_string(opts.tracked_path))")
161+
end
162+
isempty(coverage_file) || push!(exeflags, "--code-coverage=$coverage_file")
163+
end
164+
end
165+
143166
return exeflags, env
144167
end
145168

0 commit comments

Comments
 (0)