Skip to content

Commit

Permalink
improve printing when running tagets (#536)
Browse files Browse the repository at this point in the history
* improve printing when running tagets
  • Loading branch information
KristofferC committed Jul 27, 2018
1 parent 37d88e3 commit 5278d2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions stdlib/Pkg/src/Display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ' '
Expand Down
17 changes: 13 additions & 4 deletions stdlib/Pkg/src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions stdlib/Pkg/src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5278d2a

Please sign in to comment.