From 134f3e7dfaa04511a2f81f4a40cdc85f4e433706 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 23 Jan 2023 10:06:02 -0500 Subject: [PATCH] Switch remaining julia code bool envs to get_bool_envs (#48383) --- base/errorshow.jl | 9 +++------ contrib/generate_precompile.jl | 2 +- stdlib/LinearAlgebra/test/special.jl | 2 +- stdlib/Profile/src/Profile.jl | 2 +- test/choosetests.jl | 6 +----- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/base/errorshow.jl b/base/errorshow.jl index 8f34424b359a8..e99253656d4e4 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -372,12 +372,9 @@ function showerror_nostdio(err, msg::AbstractString) ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, "\n") end -stacktrace_expand_basepaths()::Bool = - tryparse(Bool, get(ENV, "JULIA_STACKTRACE_EXPAND_BASEPATHS", "false")) === true -stacktrace_contract_userdir()::Bool = - tryparse(Bool, get(ENV, "JULIA_STACKTRACE_CONTRACT_HOMEDIR", "true")) === true -stacktrace_linebreaks()::Bool = - tryparse(Bool, get(ENV, "JULIA_STACKTRACE_LINEBREAKS", "false")) === true +stacktrace_expand_basepaths()::Bool = Base.get_bool_env("JULIA_STACKTRACE_EXPAND_BASEPATHS", false) === true +stacktrace_contract_userdir()::Bool = Base.get_bool_env("JULIA_STACKTRACE_CONTRACT_HOMEDIR", true) === true +stacktrace_linebreaks()::Bool = Base.get_bool_env("JULIA_STACKTRACE_LINEBREAKS", false) === true function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()) is_arg_types = isa(ex.args, DataType) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index 0db045661b9ba..76956fac24f18 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -23,7 +23,7 @@ const PARALLEL_PRECOMPILATION = true const debug_output = devnull # or stdout # Disable fancy printing -const fancyprint = (stdout isa Base.TTY) && (get(ENV, "CI", nothing) != "true") +const fancyprint = (stdout isa Base.TTY) && Base.get_bool_env("CI", false) !== true ## CTRL_C = '\x03' diff --git a/stdlib/LinearAlgebra/test/special.jl b/stdlib/LinearAlgebra/test/special.jl index 465c9ad5a4951..df845ba3110da 100644 --- a/stdlib/LinearAlgebra/test/special.jl +++ b/stdlib/LinearAlgebra/test/special.jl @@ -291,7 +291,7 @@ end @testset "concatenations of annotated types" begin N = 4 # The tested annotation types - testfull = Bool(parse(Int,(get(ENV, "JULIA_TESTFULL", "0")))) + testfull = Base.get_bool_env("JULIA_TESTFULL", false) utriannotations = (UpperTriangular, UnitUpperTriangular) ltriannotations = (LowerTriangular, UnitLowerTriangular) triannotations = (utriannotations..., ltriannotations...) diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 46d56a879cf6d..518dc54c7f757 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -38,7 +38,7 @@ function profile_printing_listener() while true wait(PROFILE_PRINT_COND[]) peek_report[]() - if get(ENV, "JULIA_PROFILE_PEEK_HEAP_SNAPSHOT", nothing) === "1" + if Base.get_bool_env("JULIA_PROFILE_PEEK_HEAP_SNAPSHOT", false) === true println(stderr, "Saving heap snapshot...") fname = take_heap_snapshot() println(stderr, "Heap snapshot saved to `$(fname)`") diff --git a/test/choosetests.jl b/test/choosetests.jl index 23b3ab8dd342a..34737fe255343 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -180,11 +180,7 @@ function choosetests(choices = []) net_required_for = filter!(in(tests), NETWORK_REQUIRED_LIST) net_on = true - JULIA_TEST_NETWORKING_AVAILABLE = get(ENV, "JULIA_TEST_NETWORKING_AVAILABLE", "") |> - strip |> - lowercase |> - s -> tryparse(Bool, s) |> - x -> x === true + JULIA_TEST_NETWORKING_AVAILABLE = Base.get_bool_env("JULIA_TEST_NETWORKING_AVAILABLE", false) === true # If the `JULIA_TEST_NETWORKING_AVAILABLE` environment variable is set to `true`, we # always set `net_on` to `true`. # Otherwise, we set `net_on` to true if and only if networking is actually available.