Skip to content

Commit

Permalink
Add (optional) progress report in sanity_check
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobaldassi committed Jan 5, 2018
1 parent 7b636b5 commit 698be15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
Scan the graph for (explicit or implicit) contradictions. Returns a list of problematic
(package,version) combinations.
"""
function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}())
function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}(); verbose = true)
req_inds = graph.req_inds
fix_inds = graph.fix_inds

Expand Down Expand Up @@ -107,8 +107,18 @@ function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}())

checked = falses(nv)

last_str_len = 0

i = 1
for (p,vn) in vers
if verbose
frac_compl = i / nv
print("\r", " "^last_str_len)
progr_msg = @sprintf("\r%.3i/%.3i (%i%%) — problematic so far: %i", i, nv, round(Int, 100 * frac_compl), length(problematic))
print(progr_msg)
last_str_len = length(progr_msg)
end

length(gadj[pdict[p]]) == 0 && break
checked[i] && (i += 1; continue)

Expand Down Expand Up @@ -156,6 +166,7 @@ function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}())

i += 1
end
verbose && println()

return sort!(problematic)
end
Expand Down
2 changes: 1 addition & 1 deletion test/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function sanity_tst(deps_data, expected_result; pkgs=[])
@show deps_data
@show pkgs
end
result = sanity_check(graph, Set(pkguuid(p) for p in pkgs))
result = sanity_check(graph, Set(pkguuid(p) for p in pkgs), verbose = VERBOSE)

length(result) == length(expected_result) || return false
expected_result_uuid = [(id(p), vn) for (p,vn) in expected_result]
Expand Down

0 comments on commit 698be15

Please sign in to comment.