Skip to content

Commit

Permalink
Deprecate verbose flag, tweak some logging code
Browse files Browse the repository at this point in the history
There is no point in Coverage.LCOV.readfolder and Coverage.clean_folder
reporting every file they did *not* process; this just clogs up build logs,
and almost always is useless; so change this from @info to @debug.

Also, by default user won't want to know the JSON replies of Codecov and
Coveralls, nor the exact URL we used to submit to Codecov, so change those
from @info to @debug as well.

On the other hand, knowing which files actually are being processed *is*
useful, so add an @info message for that (I recently had an exception thrown
in that code and had a hard time figuring out which file was being proceed, so
this will help).

Finally, deprecate the `verbose` keyword flag; instead, users should adjust the
logging level to suppress or show various messages.
  • Loading branch information
fingolfin committed Jun 17, 2019
1 parent 8721dce commit c66123e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/Coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module Coverage
# Keep track of the combined coverage
full_coverage = CovCount[]
for file in files
@info "Coverage.process_cov: processing $file"
coverage = CovCount[]
for line in eachline(file)
# Columns 1:9 contain the coverage count
Expand Down Expand Up @@ -232,7 +233,7 @@ module Coverage
where Coverage is called from the root directory of a package.
"""
function process_folder(folder="src")
@info """Coverage.process_folder: Searching $folder for .jl files..."""
@info "Coverage.process_folder: Searching $folder for .jl files..."
source_files = FileCoverage[]
files = readdir(folder)
for file in files
Expand All @@ -242,7 +243,7 @@ module Coverage
if splitext(fullfile)[2] == ".jl"
push!(source_files, process_file(fullfile, folder))
else
@info "Coverage.process_folder: Skipping $file, not a .jl file"
@debug "Coverage.process_folder: Skipping $file, not a .jl file"
end
elseif isdir(fullfile)
# If it is a folder, recursively traverse
Expand Down
26 changes: 13 additions & 13 deletions src/codecovio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,24 @@ module Codecov
"""
function submit_generic(fcs::Vector{FileCoverage}; kwargs...)
@assert length(kwargs) > 0
dry_run = false
verbose = true
for (k,v) in kwargs
if k == :dry_run
dry_run = true
end
if k == :verbose
verbose = v
end
dry_run = get(kwargs, :dry_run, false)
if haskey(kwargs, :verbose)
Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " *
"JULIA_DEBUG=Coverage for verbose output", :submit_generic)
verbose = kwargs[:verbose]
else
verbose = false
end
uri_str = construct_uri_string(;kwargs...)

if verbose
@info "Codecov.io API URL:\n" * mask_token(uri_str)
end
verbose && @info "Submitting data to Codecov..."
verbose && @debug "Codecov.io API URL:\n" * mask_token(uri_str)

if !dry_run
heads = Dict("Content-Type" => "application/json")
data = to_json(fcs)
req = HTTP.post(uri_str; body = JSON.json(data), headers = heads)
@info "Result of submission:" * String(req)
@debug "Result of submission:" * String(req)
end
end

Expand All @@ -225,6 +222,9 @@ module Codecov

uri_str = "$(codecov_url)/upload/v2?"
for (k,v) in kwargs
# add all except a few special key/value pairs to the URL
# (:verbose is there for backwards compatibility with versions
# of this code that treated it in a special way)
if k != :codecov_url && k != :dry_run && k != :verbose
uri_str = "$(uri_str)&$(k)=$(v)"
end
Expand Down
18 changes: 15 additions & 3 deletions src/coveralls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ module Coveralls
on TravisCI, AppVeyor or Jenkins. If running locally, use `submit_local`.
"""
function submit(fcs::Vector{FileCoverage}; kwargs...)
verbose = get(kwargs, :verbose, true)
if haskey(kwargs, :verbose)
Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " *
"JULIA_DEBUG=Coverage for verbose output", :submit_generic)
verbose = kwargs[:verbose]
else
verbose = false
end
data = prepare_request(fcs, false)
post_request(data, verbose)
end
Expand Down Expand Up @@ -157,16 +163,22 @@ module Coveralls
git_info can be either a `Dict` or a function that returns a `Dict`.
"""
function submit_local(fcs::Vector{FileCoverage}, git_info=query_git_info; kwargs...)
if haskey(kwargs, :verbose)
Base.depwarn("The verbose keyword argument is deprecated, set the environment variable " *
"JULIA_DEBUG=Coverage for verbose output", :submit_generic)
verbose = kwargs[:verbose]
else
verbose = false
end
data = prepare_request(fcs, true, git_info)
verbose = get(kwargs, :verbose, true)
post_request(data, verbose)
end

# posts the actual request given the data
function post_request(data, verbose)
verbose && @info "Submitting data to Coveralls..."
req = HTTP.post("https://coveralls.io/api/v1/jobs", HTTP.Form(makebody(data)))
verbose && @info "Result of submission:\n" * String(req.body)
verbose && @debug "Result of submission:\n" * String(req.body)
end

# adds the repo token to the data
Expand Down
2 changes: 1 addition & 1 deletion src/lcov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function readfolder(folder)
if endswith(fullfile, ".info")
append!(source_files, readfile(fullfile))
else
@info "Coverage.LCOV.readfolder: Skipping $file, not a .info file"
@debug "Coverage.LCOV.readfolder: Skipping $file, not a .info file"
end
elseif isdir(fullfile)
# If it is a folder, recursively traverse
Expand Down

0 comments on commit c66123e

Please sign in to comment.