Skip to content

Commit

Permalink
don't show Environment: in versioninfo output when env is empty (J…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and ararslan committed May 10, 2018
1 parent ee4b18f commit 6fb4569
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 8 additions & 11 deletions stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,14 @@ function versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false)
println(io, " LIBM: ",Base.libm_name)
println(io, " LLVM: libLLVM-",Base.libllvm_version," (", Sys.JIT, ", ", Sys.CPU_NAME, ")")

println(io, "Environment:")
for (k,v) in ENV
if occursin(r"JULIA", String(k))
println(io, " $(k) = $(v)")
end
end
if verbose
for (k,v) in ENV
if occursin(r"PATH|FLAG|^TERM$|HOME", String(k))
println(io, " $(k) = $(v)")
end
env_strs = [String[ " $(k) = $(v)" for (k,v) in ENV if occursin(r"JULIA", k)];
(verbose ?
String[ " $(k) = $(v)" for (k,v) in ENV if occursin(r"PATH|FLAG|^TERM$|HOME", k)] :
[])]
if !isempty(env_strs)
println(io, "Environment:")
for str in env_strs
println(io, str)
end
end
if packages || verbose
Expand Down
6 changes: 6 additions & 0 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ end
@test isempty(readdir(dir))
end
end
let exename = `$(Base.julia_cmd()) --startup-file=no`
@test !occursin("Environment:", read(setenv(`$exename -e 'using InteractiveUtils; versioninfo()'`,
String[]), String))
@test occursin("Environment:", read(setenv(`$exename -e 'using InteractiveUtils; versioninfo()'`,
String["JULIA_CPU_CORES=1"]), String))
end
end

const curmod = @__MODULE__
Expand Down

0 comments on commit 6fb4569

Please sign in to comment.