From 5278d2ab2dc6961c5492b140923fb850179454aa Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Thu, 26 Jul 2018 20:52:23 +0200 Subject: [PATCH] improve printing when running tagets (#536) * improve printing when running tagets --- stdlib/Pkg/src/Display.jl | 2 ++ stdlib/Pkg/src/Operations.jl | 17 +++++++++++++---- stdlib/Pkg/src/Types.jl | 5 +++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/stdlib/Pkg/src/Display.jl b/stdlib/Pkg/src/Display.jl index 0eb0149d54338..415e0ba5d57c9 100644 --- a/stdlib/Pkg/src/Display.jl +++ b/stdlib/Pkg/src/Display.jl @@ -143,6 +143,8 @@ function print_diff(io::IO, ctx::Context, diff::Vector{DiffEntry}, status=false) pkgid = Base.PkgId(x.uuid, x.name) package_downloaded = pkgid in keys(Base.loaded_modules) || Base.locate_package(pkgid) !== nothing + # Package download detection doesnt work properly when runn running targets + ctx.currently_running_target && (package_downloaded = true) if x.old != nothing && x.new != nothing if x.old ≈ x.new verb = ' ' diff --git a/stdlib/Pkg/src/Operations.jl b/stdlib/Pkg/src/Operations.jl index 1cbd784986f4c..6dd0f14fa02ba 100644 --- a/stdlib/Pkg/src/Operations.jl +++ b/stdlib/Pkg/src/Operations.jl @@ -8,7 +8,7 @@ import LibGit2 import REPL using REPL.TerminalMenus -using ..Types, ..GraphType, ..Resolve, ..Pkg2, ..BinaryProvider, ..GitTools +using ..Types, ..GraphType, ..Resolve, ..Pkg2, ..BinaryProvider, ..GitTools, ..Display import ..depots, ..devdir, ..Types.uuid_julia function find_installed(name::String, uuid::UUID, sha1::SHA1) @@ -744,6 +744,7 @@ end function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::PackageSpec; might_need_to_resolve=false) # localctx is the context for the temporary environment we run the testing / building in localctx = deepcopy(mainctx) + localctx.currently_running_target = true # If pkg or its dependencies are checked out, we will need to resolve # unless we already have resolved for the current environment, which the calleer indicates # with `might_need_to_resolve` @@ -830,8 +831,11 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag end write_env(localctx, display_diff = false) will_resolve && build_versions(localctx, new) + sep = Sys.iswindows() ? ';' : ':' - withenv(f, "JULIA_LOAD_PATH" => "@$sep$tmpdir$sep$(Types.stdlib_dir())") + withenv("JULIA_LOAD_PATH" => "@$sep$tmpdir$sep$(Types.stdlib_dir())") do + f(localctx) + end end end @@ -1006,7 +1010,8 @@ function build_versions(ctx::Context, uuids::Vector{UUID}; might_need_to_resolve @error "Error building `$name`$last_lines: \n$log_show$full_log_at" end end - with_dependencies_loadable_at_toplevel(ctx, PackageSpec(name, uuid, version); might_need_to_resolve=might_need_to_resolve) do + with_dependencies_loadable_at_toplevel(ctx, PackageSpec(name, uuid, version); + might_need_to_resolve=might_need_to_resolve) do localctx run_build() end end @@ -1239,7 +1244,11 @@ function test(ctx::Context, pkgs::Vector{PackageSpec}; coverage=false) push!(pkgs_errored, pkg.name) end end - with_dependencies_loadable_at_toplevel(ctx, pkg; might_need_to_resolve=true) do + with_dependencies_loadable_at_toplevel(ctx, pkg; might_need_to_resolve=true) do localctx + if !Types.is_project_uuid(ctx.env, pkg.uuid) + Display.status(localctx, PKGMODE_MANIFEST) + end + run_test() end end diff --git a/stdlib/Pkg/src/Types.jl b/stdlib/Pkg/src/Types.jl index 9c46bcfa7c7a3..dffdc68fe30ac 100644 --- a/stdlib/Pkg/src/Types.jl +++ b/stdlib/Pkg/src/Types.jl @@ -339,6 +339,7 @@ Base.@kwdef mutable struct Context graph_verbose::Bool = false stdlibs::Dict{UUID,String} = gather_stdlib_uuids() # Remove next field when support for Pkg2 CI scripts is removed + currently_running_target::Bool = false old_pkg2_clone_name::String = "" end @@ -1096,7 +1097,7 @@ function write_env(ctx::Context; display_diff=true) project = deepcopy(env.project) isempty(project["deps"]) && delete!(project, "deps") if !isempty(project) || ispath(env.project_file) - if display_diff + if display_diff && !(ctx.currently_running_target) printpkgstyle(ctx, :Updating, pathrepr(ctx, env.project_file)) Pkg.Display.print_project_diff(ctx, old_env, env) end @@ -1109,7 +1110,7 @@ function write_env(ctx::Context; display_diff=true) end # update the manifest file if !isempty(env.manifest) || ispath(env.manifest_file) - if display_diff + if display_diff && !(ctx.currently_running_target) printpkgstyle(ctx, :Updating, pathrepr(ctx, env.manifest_file)) Pkg.Display.print_manifest_diff(ctx, old_env, env) end