Skip to content

Commit

Permalink
Remove verbose flag, change some @info to @debug
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, get rid of the `verbose` keyword flag; instead, users can adjust the
logging level to suppress or show various messages.
  • Loading branch information
fingolfin committed Mar 11, 2019
1 parent 18652e7 commit faa0d48
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 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 @@ -219,7 +220,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 @@ -229,7 +230,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
20 changes: 5 additions & 15 deletions src/codecovio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,17 @@ 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
end
dry_run = get(kwargs, :dry_run, false)
uri_str = construct_uri_string(;kwargs...)

if verbose
@info "Codecov.io API URL:\n" * uri_str
end
@info "Submitting data to Codecov..."
@debug "Codecov.io API URL:\n" * 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,7 +215,7 @@ module Codecov

uri_str = "$(codecov_url)/upload/v2?"
for (k,v) in kwargs
if k != :codecov_url && k != :dry_run && k != :verbose
if k != :codecov_url && k != :dry_run
uri_str = "$(uri_str)&$(k)=$(v)"
end
end
Expand Down
12 changes: 5 additions & 7 deletions src/coveralls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ module Coveralls
on TravisCI, AppVeyor or Jenkins. If running locally, use `submit_local`.
"""
function submit(fcs::Vector{FileCoverage}; kwargs...)
verbose = get(kwargs, :verbose, true)
data = prepare_request(fcs, false)
post_request(data, verbose)
post_request(data)
end

function prepare_request(fcs::Vector{FileCoverage}, local_env, git_info=query_git_info)
Expand Down Expand Up @@ -158,15 +157,14 @@ module Coveralls
"""
function submit_local(fcs::Vector{FileCoverage}, git_info=query_git_info; kwargs...)
data = prepare_request(fcs, true, git_info)
verbose = get(kwargs, :verbose, true)
post_request(data, verbose)
post_request(data)
end

# posts the actual request given the data
function post_request(data, verbose)
verbose && @info "Submitting data to Coveralls..."
function post_request(data)
@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)
@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 faa0d48

Please sign in to comment.