From 698be150575c40f75d9864f12fd7a5a4a604ba60 Mon Sep 17 00:00:00 2001 From: Carlo Baldassi Date: Thu, 21 Dec 2017 21:56:15 +0100 Subject: [PATCH] Add (optional) progress report in sanity_check --- src/Resolve.jl | 13 ++++++++++++- test/resolve.jl | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Resolve.jl b/src/Resolve.jl index 337d5ef1eb8dd..fe489588d24e2 100644 --- a/src/Resolve.jl +++ b/src/Resolve.jl @@ -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 @@ -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) @@ -156,6 +166,7 @@ function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}()) i += 1 end + verbose && println() return sort!(problematic) end diff --git a/test/resolve.jl b/test/resolve.jl index aa51d933fda85..ed9d18691b91b 100644 --- a/test/resolve.jl +++ b/test/resolve.jl @@ -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]