From 195084635502e095fff187aa5a577ca96fc5bd9d Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 27 Mar 2018 13:32:17 -0700 Subject: [PATCH] Revert "Deprecate DevNull, STDIN, STDOUT, and STDERR to lowercase (#25959)" This reverts commit 446085a6520d6324e5e1857aa9a3d03f21007f27. Lowercasing these identifiers conflicts with the statistical meaning of `stderr`, i.e. the standard error. This is defined in StatsBase and widely used. --- DISTRIBUTING.md | 2 +- NEWS.md | 7 ++-- base/boot.jl | 10 ++--- base/client.jl | 22 +++++----- base/clipboard.jl | 8 ++-- base/compiler/bootstrap.jl | 2 +- base/compiler/compiler.jl | 2 +- base/compiler/optimize.jl | 2 +- base/compiler/validation.jl | 4 +- base/coreio.jl | 12 +++--- base/deprecated.jl | 21 ++++------ base/docs/basedocs.jl | 6 +-- base/download.jl | 2 +- base/errorshow.jl | 2 +- base/exports.jl | 8 ++-- base/initdefs.jl | 4 +- base/io.jl | 16 ++++---- base/libuv.jl | 21 +++++----- base/loading.jl | 8 ++-- base/logging.jl | 14 +++---- base/meta.jl | 2 +- base/multimedia.jl | 10 ++--- base/precompile.jl | 4 +- base/printf.jl | 2 +- base/process.jl | 40 +++++++++---------- base/show.jl | 20 +++++----- base/stream.jl | 39 +++++++++--------- base/strings/io.jl | 4 +- base/sysimg.jl | 8 ++-- base/sysinfo.jl | 4 +- base/task.jl | 2 +- base/util.jl | 4 +- base/version.jl | 2 +- contrib/build_sysimg.jl | 2 +- contrib/julia-config.jl | 2 +- doc/src/base/base.md | 2 +- doc/src/base/constants.md | 6 +-- doc/src/base/io-network.md | 6 +-- doc/src/devdocs/stdio.md | 10 ++--- doc/src/manual/faq.md | 6 +-- doc/src/manual/modules.md | 6 +-- doc/src/manual/networking-and-streams.md | 28 ++++++------- doc/src/manual/parallel-computing.md | 6 +-- doc/src/manual/profile.md | 6 +-- doc/src/manual/running-external-programs.md | 10 ++--- doc/src/manual/types.md | 6 +-- src/rtutils.c | 4 +- stdlib/Distributed/src/cluster.jl | 22 +++++----- stdlib/Distributed/src/managers.jl | 2 +- stdlib/Distributed/src/messages.jl | 2 +- stdlib/Distributed/src/process_messages.jl | 8 ++-- stdlib/Distributed/src/remotecall.jl | 2 +- stdlib/Distributed/test/distributed_exec.jl | 6 +-- stdlib/Distributed/test/runtests.jl | 2 +- .../InteractiveUtils/src/InteractiveUtils.jl | 6 +-- stdlib/InteractiveUtils/src/codeview.jl | 14 +++---- stdlib/InteractiveUtils/src/editless.jl | 2 +- stdlib/InteractiveUtils/test/runtests.jl | 2 +- stdlib/LibGit2/test/libgit2.jl | 4 +- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 2 +- stdlib/Logging/src/ConsoleLogger.jl | 4 +- stdlib/Logging/src/Logging.jl | 2 +- stdlib/Logging/test/runtests.jl | 6 +-- stdlib/Pkg/src/Pkg.jl | 4 +- stdlib/Pkg/src/entry.jl | 4 +- stdlib/Pkg/test/pkg.jl | 16 ++++---- stdlib/Pkg3/ext/TOML/src/print.jl | 2 +- stdlib/Pkg3/src/Display.jl | 4 +- stdlib/Pkg3/src/GraphType.jl | 4 +- stdlib/Pkg3/src/Operations.jl | 4 +- stdlib/Pkg3/src/REPLMode.jl | 2 +- stdlib/Pkg3/src/Types.jl | 10 ++--- stdlib/Pkg3/src/generate.jl | 2 +- stdlib/Pkg3/src/precompile.jl | 2 +- stdlib/Printf/src/Printf.jl | 2 +- stdlib/Profile/src/Profile.jl | 8 ++-- .../REPL/src/TerminalMenus/TerminalMenus.jl | 2 +- stdlib/REPL/src/TerminalMenus/util.jl | 10 ++--- stdlib/REPL/src/docview.jl | 22 +++++----- stdlib/REPL/test/TerminalMenus/radio_menu.jl | 2 +- stdlib/REPL/test/TerminalMenus/runtests.jl | 6 +-- stdlib/REPL/test/repl.jl | 32 +++++++-------- stdlib/Random/src/RNGs.jl | 2 +- stdlib/Test/src/Test.jl | 8 ++-- stdlib/Test/src/logging.jl | 2 +- stdlib/Test/test/runtests.jl | 22 +++++----- test/boundscheck.jl | 6 +-- test/ccall.jl | 4 +- test/channels.jl | 2 +- test/cmdlineargs.jl | 12 +++--- test/compiler/compiler.jl | 6 +-- test/core.jl | 22 +++++----- test/deprecation_exec.jl | 24 +++++------ test/embedding/embedding-test.jl | 4 +- test/examples.jl | 2 +- test/file.jl | 8 ++-- test/llvmcall.jl | 2 +- test/logging.jl | 6 +-- test/meta.jl | 2 +- test/misc.jl | 22 +++++----- test/ranges.jl | 2 +- test/read.jl | 22 +++++----- test/runtests.jl | 10 ++--- test/show.jl | 10 ++--- test/spawn.jl | 36 ++++++++--------- test/threads.jl | 2 +- 106 files changed, 432 insertions(+), 444 deletions(-) diff --git a/DISTRIBUTING.md b/DISTRIBUTING.md index b3cdadf8f9166..7ac1d689c60a8 100644 --- a/DISTRIBUTING.md +++ b/DISTRIBUTING.md @@ -375,7 +375,7 @@ for result in eachrow(results) end ``` -This will write color-coded lines to `stdout`. +This will write color-coded lines to STDOUT. All lines in red must be investigated as they signify potential breakages caused by the backport version. Lines in yellow should be looked into since it means a package ran on one version but diff --git a/NEWS.md b/NEWS.md index 1b8a039330f2a..72cc7a8c26c86 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1116,9 +1116,6 @@ Deprecated or removed * The fallback method `^(x, p::Integer)` is deprecated. If your type relied on this definition, add a method such as `^(x::MyType, p::Integer) = Base.power_by_squaring(x, p)` ([#23332]). - * `DevNull`, `STDIN`, `STDOUT`, and `STDERR` have been renamed to `devnull`, `stdin`, `stdout`, - and `stderr`, respectively ([#25786]). - * `wait` and `fetch` on `Task` now resemble the interface of `Future`. * `showcompact(io, x...)` has been deprecated in favor of @@ -1128,6 +1125,8 @@ Deprecated or removed * `isupper`, `islower`, `ucfirst` and `lcfirst` have been deprecated in favor of `isuppercase`, `islowercase`, `uppercasefirst` and `lowercasefirst`, respectively ([#26442]). + * `wait` and `fetch` on `Task` now resemble the interface of `Future` + Command-line option changes --------------------------- @@ -1436,4 +1435,4 @@ Command-line option changes [#26286]: https://github.com/JuliaLang/julia/issues/26286 [#26436]: https://github.com/JuliaLang/julia/issues/26436 [#26442]: https://github.com/JuliaLang/julia/issues/26442 -[#26600]: https://github.com/JuliaLang/julia/issues/26600 \ No newline at end of file +[#26600]: https://github.com/JuliaLang/julia/issues/26600 diff --git a/base/boot.jl b/base/boot.jl index 91fa20d71d0b0..c6f3a0fba05d2 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -443,8 +443,8 @@ atdoc!(λ) = global atdoc = λ abstract type IO end struct CoreSTDOUT <: IO end struct CoreSTDERR <: IO end -const stdout = CoreSTDOUT() -const stderr = CoreSTDERR() +const STDOUT = CoreSTDOUT() +const STDERR = CoreSTDERR() io_pointer(::CoreSTDOUT) = Intrinsics.pointerref(Intrinsics.cglobal(:jl_uv_stdout, Ptr{Cvoid}), 1, 1) io_pointer(::CoreSTDERR) = Intrinsics.pointerref(Intrinsics.cglobal(:jl_uv_stderr, Ptr{Cvoid}), 1, 1) @@ -468,9 +468,9 @@ print(io::IO, @nospecialize(x), @nospecialize a...) = (print(io, x); print(io, a println(io::IO) = (write(io, 0x0a); nothing) # 0x0a = '\n' println(io::IO, @nospecialize x...) = (print(io, x...); println(io)) -show(@nospecialize a) = show(stdout, a) -print(@nospecialize a...) = print(stdout, a...) -println(@nospecialize a...) = println(stdout, a...) +show(@nospecialize a) = show(STDOUT, a) +print(@nospecialize a...) = print(STDOUT, a...) +println(@nospecialize a...) = println(STDOUT, a...) struct GeneratedFunctionStub gen diff --git a/base/client.jl b/base/client.jl index 40b6867a4776d..bed223175a977 100644 --- a/base/client.jl +++ b/base/client.jl @@ -165,7 +165,7 @@ function display_error(io::IO, er, bt) showerror(IOContext(io, :limit => true), er, bt) println(io) end -display_error(er, bt) = display_error(stderr, er, bt) +display_error(er, bt) = display_error(STDERR, er, bt) display_error(er) = display_error(er, []) function eval_user_input(@nospecialize(ast), show_value::Bool) @@ -189,7 +189,7 @@ function eval_user_input(@nospecialize(ast), show_value::Bool) try invokelatest(display, value) catch err - println(stderr, "Evaluation succeeded, but an error occurred while showing value of type ", typeof(value), ":") + println(STDERR, "Evaluation succeeded, but an error occurred while showing value of type ", typeof(value), ":") rethrow(err) end println() @@ -198,17 +198,17 @@ function eval_user_input(@nospecialize(ast), show_value::Bool) break catch err if errcount > 0 - println(stderr, "SYSTEM: show(lasterr) caused an error") + println(STDERR, "SYSTEM: show(lasterr) caused an error") end errcount, lasterr = errcount+1, err if errcount > 2 - println(stderr, "WARNING: it is likely that something important is broken, and Julia will not be able to continue normally") + println(STDERR, "WARNING: it is likely that something important is broken, and Julia will not be able to continue normally") break end bt = catch_backtrace() end end - isa(stdin, TTY) && println() + isa(STDIN, TTY) && println() nothing end @@ -328,7 +328,7 @@ function exec_options(opts) end repl |= is_interactive if repl - interactiveinput = isa(stdin, TTY) + interactiveinput = isa(STDIN, TTY) if interactiveinput global is_interactive = true banner = (opts.banner != 0) # --banner!=no @@ -369,8 +369,8 @@ function __atreplinit(repl) try f(repl) catch err - showerror(stderr, err) - println(stderr) + showerror(STDERR, err) + println(STDERR) end end end @@ -397,7 +397,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil if interactive && isassigned(REPL_MODULE_REF) invokelatest(REPL_MODULE_REF[]) do REPL term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb") - term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr) + term = REPL.Terminals.TTYTerminal(term_env, STDIN, STDOUT, STDERR) color_set || (global have_color = REPL.Terminals.hascolor(term)) banner && REPL.banner(term, term) if term.term_type == "dumb" @@ -419,7 +419,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil @warn "REPL provider not available: using basic fallback" end banner && Base.banner() - let input = stdin + let input = STDIN if isa(input, File) || isa(input, IOStream) # for files, we can slurp in the whole thing at once ex = parse_input_line(read(input, String)) @@ -437,7 +437,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil while isopen(input) || !eof(input) if interactive print("julia> ") - flush(stdout) + flush(STDOUT) end eval_user_input(parse_input_line(input), true) end diff --git a/base/clipboard.jl b/base/clipboard.jl index 7aa6d71ef9ef6..42c753376baaf 100644 --- a/base/clipboard.jl +++ b/base/clipboard.jl @@ -4,7 +4,7 @@ if Sys.isapple() function clipboard(x) - open(pipeline(`pbcopy`, stderr=stderr), "w") do io + open(pipeline(`pbcopy`, stderr=STDERR), "w") do io print(io, x) end end @@ -28,7 +28,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD global _clipboardcmd _clipboardcmd !== nothing && return _clipboardcmd for cmd in (:xclip, :xsel) - success(pipeline(`which $cmd`, devnull)) && return _clipboardcmd = cmd + success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd end pkgs = @static if Sys.islinux() "xsel or xclip" @@ -43,7 +43,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD if cmd === nothing error("unexpected clipboard command: $c") end - open(pipeline(cmd, stderr=stderr), "w") do io + open(pipeline(cmd, stderr=STDERR), "w") do io print(io, x) end end @@ -53,7 +53,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD if cmd === nothing error("unexpected clipboard command: $c") end - read(pipeline(cmd, stderr=stderr), String) + read(pipeline(cmd, stderr=STDERR), String) end elseif Sys.iswindows() diff --git a/base/compiler/bootstrap.jl b/base/compiler/bootstrap.jl index 42d68cfa10c6b..40ed370c25b47 100644 --- a/base/compiler/bootstrap.jl +++ b/base/compiler/bootstrap.jl @@ -15,7 +15,7 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call, optimize, run_p x = T_IFUNC[i] push!(fs, x[3]) else - println(stderr, "WARNING: tfunc missing for ", reinterpret(IntrinsicFunction, Int32(i))) + println(STDERR, "WARNING: tfunc missing for ", reinterpret(IntrinsicFunction, Int32(i))) end end for f in fs diff --git a/base/compiler/compiler.jl b/base/compiler/compiler.jl index 6ed61657292b0..c32d322f0e29e 100644 --- a/base/compiler/compiler.jl +++ b/base/compiler/compiler.jl @@ -4,7 +4,7 @@ getfield(getfield(Main, :Core), :eval)(getfield(Main, :Core), :(baremodule Compi using Core.Intrinsics, Core.IR -import Core: print, println, show, write, unsafe_write, stdout, stderr, +import Core: print, println, show, write, unsafe_write, STDOUT, STDERR, _apply, svec, apply_type, Builtin, IntrinsicFunction, MethodInstance const getproperty = getfield diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 1ed62775d08aa..f974087f30363 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -3827,7 +3827,7 @@ macro check_ast(ctx, ex) println("Code:") println(ctx.sv.src) println("Value Info Map:") - show_info(stdout, ctx.infomap, ctx) + show_info(STDOUT, ctx.infomap, ctx) ccall(:abort, Union{}, ()) end end diff --git a/base/compiler/validation.jl b/base/compiler/validation.jl index 90d08481a9420..46898989c4982 100644 --- a/base/compiler/validation.jl +++ b/base/compiler/validation.jl @@ -61,10 +61,10 @@ function validate_code_in_debug_mode(linfo::MethodInstance, src::CodeInfo, kind: if !isempty(errors) for e in errors if linfo.def isa Method - println(stderr, "WARNING: Encountered invalid ", kind, " code for method ", + println(STDERR, "WARNING: Encountered invalid ", kind, " code for method ", linfo.def, ": ", e) else - println(stderr, "WARNING: Encountered invalid ", kind, " code for top level expression in ", + println(STDERR, "WARNING: Encountered invalid ", kind, " code for top level expression in ", linfo.def, ": ", e) end end diff --git a/base/coreio.jl b/base/coreio.jl index e901cdec10e39..fcc6bd519e355 100644 --- a/base/coreio.jl +++ b/base/coreio.jl @@ -1,11 +1,11 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -print(xs...) = print(stdout::IO, xs...) -println(xs...) = println(stdout::IO, xs...) +print(xs...) = print(STDOUT::IO, xs...) +println(xs...) = println(STDOUT::IO, xs...) println(io::IO) = print(io, '\n') struct DevNullStream <: IO end -const devnull = DevNullStream() +const DevNull = DevNullStream() isreadable(::DevNullStream) = false iswritable(::DevNullStream) = true isopen(::DevNullStream) = true @@ -26,6 +26,6 @@ let CoreIO = Union{Core.CoreSTDOUT, Core.CoreSTDERR} unsafe_write(io::CoreIO, x::Ptr{UInt8}, nb::UInt) = Core.unsafe_write(io, x, nb) end -stdin = devnull -stdout = Core.stdout -stderr = Core.stderr +STDIN = DevNull +STDOUT = Core.STDOUT +STDERR = Core.STDERR diff --git a/base/deprecated.jl b/base/deprecated.jl index 4ad071716d703..369f704d2e96b 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -127,7 +127,7 @@ macro deprecate_binding(old, new, export_old=true, dep_message=:nothing, constan return Expr(:toplevel, export_old ? Expr(:export, esc(old)) : nothing, Expr(:const, Expr(:(=), esc(Symbol(string("_dep_message_",old))), esc(dep_message))), - constant ? Expr(:const, Expr(:(=), esc(old), esc(new))) : Expr(:(=), esc(old), esc(new)), + Expr(:const, Expr(:(=), esc(old), esc(new))), Expr(:call, :deprecate, __module__, Expr(:quote, old))) end @@ -966,14 +966,14 @@ function info(io::IO, msg...; prefix="INFO: ") print(io, String(take!(buf))) return end -info(msg...; prefix="INFO: ") = info(stderr, msg..., prefix=prefix) +info(msg...; prefix="INFO: ") = info(STDERR, msg..., prefix=prefix) # print a warning only once const have_warned = Set() warn_once(io::IO, msg...) = warn(io, msg..., once=true) -warn_once(msg...) = warn(stderr, msg..., once=true) +warn_once(msg...) = warn(STDERR, msg..., once=true) """ warn([io, ] msg..., [prefix="WARNING: ", once=false, key=nothing, bt=nothing, filename=nothing, lineno::Int=0]) @@ -1023,19 +1023,19 @@ julia> warn("Beep Beep") WARNING: Beep Beep ``` """ -warn(msg...; kw...) = warn(stderr, msg...; kw...) +warn(msg...; kw...) = warn(STDERR, msg...; kw...) warn(io::IO, err::Exception; prefix="ERROR: ", kw...) = warn(io, sprint(showerror, err), prefix=prefix; kw...) warn(err::Exception; prefix="ERROR: ", kw...) = - warn(stderr, err, prefix=prefix; kw...) + warn(STDERR, err, prefix=prefix; kw...) info(io::IO, err::Exception; prefix="ERROR: ", kw...) = info(io, sprint(showerror, err), prefix=prefix; kw...) info(err::Exception; prefix="ERROR: ", kw...) = - info(stderr, err, prefix=prefix; kw...) + info(STDERR, err, prefix=prefix; kw...) # issue #25082 @deprecate_binding Void Nothing @@ -1487,13 +1487,6 @@ function (r::Regex)(s) occursin(r, s) end -# Issue #25786 -@deprecate_binding DevNull devnull -# TODO: When these are removed, also remove the uppercase variants in libuv.jl and stream.jl -@deprecate_binding STDIN stdin true nothing false -@deprecate_binding STDOUT stdout true nothing false -@deprecate_binding STDERR stderr true nothing false - # PR 25062 @deprecate(link_pipe(pipe; julia_only_read = true, julia_only_write = true), link_pipe!(pipe, reader_supports_async = julia_only_read, writer_supports_async = julia_only_write), @@ -1553,7 +1546,7 @@ end @deprecate Crand Libc.rand false @deprecate Csrand Libc.srand false -@deprecate showcompact(x) show(IOContext(stdout, :compact => true), x) +@deprecate showcompact(x) show(IOContext(STDOUT, :compact => true), x) @deprecate showcompact(io, x) show(IOContext(io, :compact => true), x) @deprecate sprint(::typeof(showcompact), args...) sprint(show, args...; context=:compact => true) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 6a18bbc0c2296..d5107e9368f18 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -789,16 +789,16 @@ A variable referring to the last computed value, automatically set at the intera kw"ans" """ - devnull + DevNull Used in a stream redirect to discard all data written to it. Essentially equivalent to /dev/null on Unix or NUL on Windows. Usage: ```julia -run(pipeline(`cat test.txt`, devnull)) +run(pipeline(`cat test.txt`, DevNull)) ``` """ -devnull +DevNull # doc strings for code in boot.jl and built-ins diff --git a/base/download.jl b/base/download.jl index f4d564d93f0f4..be22a4aad19f3 100644 --- a/base/download.jl +++ b/base/download.jl @@ -19,7 +19,7 @@ else global downloadcmd if downloadcmd === nothing for checkcmd in (:curl, :wget, :fetch) - if success(pipeline(`which $checkcmd`, devnull)) + if success(pipeline(`which $checkcmd`, DevNull)) downloadcmd = checkcmd break end diff --git a/base/errorshow.jl b/base/errorshow.jl index fb260ffb0e99c..baec065806b11 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -290,7 +290,7 @@ function showerror_ambiguous(io::IO, meth, f, args) end #Show an error by directly calling jl_printf. -#Useful in Base submodule __init__ functions where stderr isn't defined yet. +#Useful in Base submodule __init__ functions where STDERR isn't defined yet. function showerror_nostdio(err, msg::AbstractString) stderr_stream = ccall(:jl_stderr_stream, Ptr{Cvoid}, ()) ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, msg) diff --git a/base/exports.jl b/base/exports.jl index 15de30529884f..c98f13d577b59 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -40,6 +40,7 @@ export DenseMatrix, DenseVecOrMat, DenseVector, + DevNull, Dict, Dims, Enum, @@ -134,11 +135,10 @@ export ENV, LOAD_PATH, PROGRAM_FILE, - stderr, - stdin, - stdout, + STDERR, + STDIN, + STDOUT, VERSION, - devnull, # Mathematical constants Inf, diff --git a/base/initdefs.jl b/base/initdefs.jl index 8aa8b0fa1bba4..6f7847ffa161f 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -140,8 +140,8 @@ function _atexit() try f() catch err - show(stderr, err) - println(stderr) + show(STDERR, err) + println(STDERR) end end end diff --git a/base/io.jl b/base/io.jl index f46823a14a847..82776f5be52b5 100644 --- a/base/io.jl +++ b/base/io.jl @@ -327,10 +327,10 @@ julia> rm("my_file.txt") readuntil(filename::AbstractString, args...; kw...) = open(io->readuntil(io, args...; kw...), filename) """ - readline(io::IO=stdin; keep::Bool=false) + readline(io::IO=STDIN; keep::Bool=false) readline(filename::AbstractString; keep::Bool=false) -Read a single line of text from the given I/O stream or file (defaults to `stdin`). +Read a single line of text from the given I/O stream or file (defaults to `STDIN`). When reading from a file, the text is assumed to be encoded in UTF-8. Lines in the input end with `'\\n'` or `"\\r\\n"` or the end of an input stream. When `keep` is false (as it is by default), these trailing newline characters are removed from the @@ -363,7 +363,7 @@ function readline(filename::AbstractString; chomp=nothing, keep::Bool=false) end end -function readline(s::IO=stdin; chomp=nothing, keep::Bool=false) +function readline(s::IO=STDIN; chomp=nothing, keep::Bool=false) if chomp !== nothing keep = !chomp depwarn("The `chomp=$chomp` argument to `readline` is deprecated in favor of `keep=$keep`.", :readline) @@ -380,7 +380,7 @@ function readline(s::IO=stdin; chomp=nothing, keep::Bool=false) end """ - readlines(io::IO=stdin; keep::Bool=false) + readlines(io::IO=STDIN; keep::Bool=false) readlines(filename::AbstractString; keep::Bool=false) Read all lines of an I/O stream or a file as a vector of strings. Behavior is @@ -412,7 +412,7 @@ function readlines(filename::AbstractString; kw...) readlines(f; kw...) end end -readlines(s=stdin; kw...) = collect(eachline(s; kw...)) +readlines(s=STDIN; kw...) = collect(eachline(s; kw...)) ## byte-order mark, ntoh & hton ## @@ -844,12 +844,12 @@ struct EachLine ondone::Function keep::Bool - EachLine(stream::IO=stdin; ondone::Function=()->nothing, keep::Bool=false) = + EachLine(stream::IO=STDIN; ondone::Function=()->nothing, keep::Bool=false) = new(stream, ondone, keep) end """ - eachline(io::IO=stdin; keep::Bool=false) + eachline(io::IO=STDIN; keep::Bool=false) eachline(filename::AbstractString; keep::Bool=false) Create an iterable `EachLine` object that will yield each line from an I/O stream @@ -873,7 +873,7 @@ JuliaLang is a GitHub organization. It has many members. julia> rm("my_file.txt"); ``` """ -function eachline(stream::IO=stdin; chomp=nothing, keep::Bool=false) +function eachline(stream::IO=STDIN; chomp=nothing, keep::Bool=false) if chomp !== nothing keep = !chomp depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) diff --git a/base/libuv.jl b/base/libuv.jl index 3012755e0982d..f73e4ff1ea258 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -94,31 +94,28 @@ function reinit_stdio() global uv_jl_timercb = cfunction(uv_timercb, Cvoid, Tuple{Ptr{Cvoid}}) global uv_eventloop = ccall(:jl_global_event_loop, Ptr{Cvoid}, ()) - global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ())) - global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ())) - global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ())) - global STDIN = stdin - global STDOUT = stdout - global STDERR = stderr + global STDIN = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ())) + global STDOUT = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ())) + global STDERR = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ())) end """ - stdin + STDIN Global variable referring to the standard input stream. """ -:stdin +:STDIN """ - stdout + STDOUT Global variable referring to the standard out stream. """ -:stdout +:STDOUT """ - stderr + STDERR Global variable referring to the standard error stream. """ -:stderr +:STDERR diff --git a/base/loading.jl b/base/loading.jl index 0aea2c3a22849..bf369735b0126 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1106,8 +1106,8 @@ evalfile(path::AbstractString, args::Vector) = evalfile(path, String[args...]) function create_expr_cache(input::String, output::String, concrete_deps::typeof(_concrete_dependencies), uuid::Union{Nothing,UUID}) rm(output, force=true) # Remove file if it exists code_object = """ - while !eof(stdin) - code = readuntil(stdin, '\\0') + while !eof(STDIN) + code = readuntil(STDIN, '\\0') eval(Main, Meta.parse(code)) end """ @@ -1115,8 +1115,8 @@ function create_expr_cache(input::String, output::String, concrete_deps::typeof( --output-ji $output --output-incremental=yes --startup-file=no --history-file=no --warn-overwrite=yes --color=$(have_color ? "yes" : "no") - --eval $code_object`), stderr=stderr), - "w", stdout) + --eval $code_object`), stderr=STDERR), + "w", STDOUT) in = io.in try write(in, """ diff --git a/base/logging.jl b/base/logging.jl index 1538ea64f0b9a..da1c9c72526b4 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -335,10 +335,10 @@ end try # Give up and write to STDERR, in three independent calls to # increase the odds of it getting through. - print(stderr, "Exception handling log message: ") - println(stderr, err) - println(stderr, " module=$_module file=$filepath line=$line") - println(stderr, " Second exception: ", err2) + print(STDERR, "Exception handling log message: ") + println(STDERR, err) + println(STDERR, " module=$_module file=$filepath line=$line") + println(STDERR, " Second exception: ", err2) catch end end @@ -449,7 +449,7 @@ current_logger() = current_logstate().logger #------------------------------------------------------------------------------- # SimpleLogger """ - SimpleLogger(stream=stderr, min_level=Info) + SimpleLogger(stream=STDERR, min_level=Info) Simplistic logger for logging all messages with level greater than or equal to `min_level` to `stream`. @@ -459,7 +459,7 @@ struct SimpleLogger <: AbstractLogger min_level::LogLevel message_limits::Dict{Any,Int} end -SimpleLogger(stream::IO=stderr, level=Info) = SimpleLogger(stream, level, Dict{Any,Int}()) +SimpleLogger(stream::IO=STDERR, level=Info) = SimpleLogger(stream, level, Dict{Any,Int}()) shouldlog(logger::SimpleLogger, level, _module, group, id) = get(logger.message_limits, id, 1) > 0 @@ -491,6 +491,6 @@ function handle_message(logger::SimpleLogger, level, message, _module, group, id nothing end -_global_logstate = LogState(SimpleLogger(Core.stderr, CoreLogging.Info)) +_global_logstate = LogState(SimpleLogger(Core.STDERR, CoreLogging.Info)) end # CoreLogging diff --git a/base/meta.jl b/base/meta.jl index 62b7b89a2dde9..94ef7c530440f 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -23,7 +23,7 @@ isexpr(ex, head, n::Int) = isexpr(ex, head) && length(ex.args) == n # ---- show_sexpr: print an AST as an S-expression ---- -show_sexpr(ex) = show_sexpr(stdout, ex) +show_sexpr(ex) = show_sexpr(STDOUT, ex) show_sexpr(io::IO, ex) = show_sexpr(io, ex, 0) show_sexpr(io::IO, ex, indent::Int) = show(io, ex) diff --git a/base/multimedia.jl b/base/multimedia.jl index 3ec70cc12b663..45c89d19c695a 100644 --- a/base/multimedia.jl +++ b/base/multimedia.jl @@ -251,7 +251,7 @@ function popdisplay(d::AbstractDisplay) end function reinit_displays() empty!(displays) - pushdisplay(TextDisplay(stdout)) + pushdisplay(TextDisplay(STDOUT)) end xdisplayable(D::AbstractDisplay, args...) = applicable(display, D, args...) @@ -263,15 +263,15 @@ xdisplayable(D::AbstractDisplay, args...) = applicable(display, D, args...) display(d::AbstractDisplay, mime, x) AbstractDisplay `x` using the topmost applicable display in the display stack, typically using the -richest supported multimedia output for `x`, with plain-text [`stdout`](@ref) output as a fallback. +richest supported multimedia output for `x`, with plain-text [`STDOUT`](@ref) output as a fallback. The `display(d, x)` variant attempts to display `x` on the given display `d` only, throwing a [`MethodError`](@ref) if `d` cannot display objects of this type. -In general, you cannot assume that `display` output goes to `stdout` (unlike [`print(x)`](@ref) or +In general, you cannot assume that `display` output goes to `STDOUT` (unlike [`print(x)`](@ref) or [`show(x)`](@ref)). For example, `display(x)` may open up a separate window with an image. `display(x)` means "show `x` in the best way you can for the current output device(s)." -If you want REPL-like text output that is guaranteed to go to `stdout`, use -[`show(stdout, "text/plain", x)`](@ref) instead. +If you want REPL-like text output that is guaranteed to go to `STDOUT`, use +[`show(STDOUT, "text/plain", x)`](@ref) instead. There are also two variants with a `mime` argument (a MIME type string, such as `"image/png"`), which attempt to display `x` using the requested MIME type *only*, throwing diff --git a/base/precompile.jl b/base/precompile.jl index 2f69c7f96e118..98b5435deb9bd 100644 --- a/base/precompile.jl +++ b/base/precompile.jl @@ -116,7 +116,7 @@ precompile(Tuple{Type{Markdown.MD}, Markdown.MD, Markdown.MD}) precompile(Tuple{Type{NamedTuple{(), T} where T<:Tuple}, Tuple{}}) precompile(Tuple{Type{NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}}, Tuple{Bool, Symbol}}) precompile(Tuple{Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}}, Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}) -precompile(Tuple{Type{NamedTuple{(:stderr,), Tuple{Base.IOStream}}}, Tuple{Base.IOStream}}) +precompile(Tuple{Type{NamedTuple{(:STDERR,), Tuple{Base.IOStream}}}, Tuple{Base.IOStream}}) precompile(Tuple{Type{Ptr{UInt16}}, Int64}) precompile(Tuple{Type{Ptr{UInt32}}, Int64}) precompile(Tuple{Type{REPL.LineEdit.InputAreaState}, Int64, Int64}) @@ -130,7 +130,7 @@ precompile(Tuple{Type{Symbol}, String, Int64, String}) precompile(Tuple{Type{Symbol}, String, String, Int64}) precompile(Tuple{Type{Symbol}, Symbol, Int64}) precompile(Tuple{getfield(Base, Symbol("#kw##indentation")), NamedTuple{(:tabwidth,), Tuple{Int64}}, typeof(Base.indentation), String}) -precompile(Tuple{getfield(Base, Symbol("#kw##pipeline")), NamedTuple{(:stderr,), Tuple{Base.IOStream}}, typeof(Base.pipeline), Base.Cmd}) +precompile(Tuple{getfield(Base, Symbol("#kw##pipeline")), NamedTuple{(:STDERR,), Tuple{Base.IOStream}}, typeof(Base.pipeline), Base.Cmd}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), REPL.Terminals.TTYTerminal, String}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:color,), Tuple{Symbol}}, typeof(Base.printstyled), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) diff --git a/base/printf.jl b/base/printf.jl index 3816eaf2794d6..13c132774e31c 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -1198,7 +1198,7 @@ end macro printf(args...) isempty(args) && throw(ArgumentError("@printf: called with no arguments")) if isa(args[1], AbstractString) || is_str_expr(args[1]) - _printf("@printf", :stdout, args[1], args[2:end]) + _printf("@printf", :STDOUT, args[1], args[2:end]) else (length(args) >= 2 && (isa(args[2], AbstractString) || is_str_expr(args[2]))) || throw(ArgumentError("@printf: first or second argument must be a format string")) diff --git a/base/process.jl b/base/process.jl index 77a04997bcb07..cfac35b634424 100644 --- a/base/process.jl +++ b/base/process.jl @@ -139,7 +139,7 @@ struct FileRedirect append::Bool function FileRedirect(filename, append) if lowercase(filename) == (@static Sys.iswindows() ? "nul" : "/dev/null") - @warn "For portability use devnull instead of a file redirect" maxlog=1 + @warn "For portability use DevNull instead of a file redirect" maxlog=1 end return new(filename, append) end @@ -312,13 +312,13 @@ mutable struct Process <: AbstractPipe out::Union{Redirectable, Ptr{Cvoid}}, err::Union{Redirectable, Ptr{Cvoid}}) if !isa(in, IO) - in = devnull + in = DevNull end if !isa(out, IO) - out = devnull + out = DevNull end if !isa(err, IO) - err = devnull + err = DevNull end this = new(cmd, handle, in, out, err, typemin(fieldtype(Process, :exitcode)), @@ -534,12 +534,12 @@ end # returns stdios: # A set of up to 256 stdio instructions, where each entry can be either: # | - An IO to be passed to the child -# | - devnull to pass /dev/null +# | - DevNull to pass /dev/null # | - An Filesystem.File object to redirect the output to # \ - A string specifying a filename to be opened spawn_opts_swallow(stdios::StdIOSet) = (stdios,) -spawn_opts_swallow(in::Redirectable=devnull, out::Redirectable=devnull, err::Redirectable=devnull, args...) = +spawn_opts_swallow(in::Redirectable=DevNull, out::Redirectable=DevNull, err::Redirectable=DevNull, args...) = ((in, out, err), args...) spawn_opts_inherit(stdios::StdIOSet) = (stdios,) # pass original descriptors to child processes by default, because we might @@ -556,16 +556,16 @@ function eachline(cmd::AbstractCmd; chomp=nothing, keep::Bool=false) keep = !chomp depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) end - _stdout = Pipe() - processes = _spawn(cmd, (devnull, _stdout, stderr)) - close(_stdout.in) - out = _stdout.out + stdout = Pipe() + processes = spawn(cmd, (DevNull,stdout,STDERR)) + close(stdout.in) + out = stdout.out # implicitly close after reading lines, since we opened return EachLine(out, keep=keep, ondone=()->(close(out); success(processes) || pipeline_error(processes)))::EachLine end -function open(cmds::AbstractCmd, mode::AbstractString, other::Redirectable=devnull) +function open(cmds::AbstractCmd, mode::AbstractString, other::Redirectable=DevNull) if mode == "r+" || mode == "w+" return open(cmds, other, read = true, write = true) elseif mode == "r" @@ -579,7 +579,7 @@ end # return a Process object to read-to/write-from the pipeline """ - open(command, stdio=devnull; write::Bool = false, read::Bool = !write) + open(command, stdio=DevNull; write::Bool = false, read::Bool = !write) Start running `command` asynchronously, and return a tuple `(stream,process)`. If `read` is true, then `stream` reads from the process's standard output and `stdio` optionally @@ -587,18 +587,18 @@ specifies the process's standard input stream. If `write` is true, then `stream the process's standard input and `stdio` optionally specifies the process's standard output stream. """ -function open(cmds::AbstractCmd, other::Redirectable=devnull; write::Bool = false, read::Bool = !write) +function open(cmds::AbstractCmd, other::Redirectable=DevNull; write::Bool = false, read::Bool = !write) if read && write - other === devnull || throw(ArgumentError("no other stream can be specified in read-write mode")) + other === DevNull || throw(ArgumentError("no other stream can be specified in read-write mode")) in = Pipe() out = Pipe() - processes = _spawn(cmds, (in,out,stderr)) + processes = _spawn(cmds, (in,out,STDERR)) close(in.out) close(out.in) elseif read in = other out = Pipe() - processes = _spawn(cmds, (in,out,stderr)) + processes = _spawn(cmds, (in,out,STDERR)) close(out.in) if isa(processes, ProcessChain) # for open(cmd) deprecation processes = ProcessChain(processes, :out) @@ -608,7 +608,7 @@ function open(cmds::AbstractCmd, other::Redirectable=devnull; write::Bool = fals elseif write in = Pipe() out = other - processes = _spawn(cmds, (in,out,stderr)) + processes = _spawn(cmds, (in,out,STDERR)) close(in.out) if isa(processes, ProcessChain) # for open(cmd) deprecation processes = ProcessChain(processes, :in) @@ -622,7 +622,7 @@ function open(cmds::AbstractCmd, other::Redirectable=devnull; write::Bool = fals end """ - open(f::Function, command, mode::AbstractString="r", stdio=devnull) + open(f::Function, command, mode::AbstractString="r", stdio=DevNull) Similar to `open(command, mode, stdio)`, but calls `f(stream)` on the resulting process stream, then closes the input stream and waits for the process to complete. @@ -643,7 +643,7 @@ function open(f::Function, cmds::AbstractCmd, args...) end function read(cmd::AbstractCmd) - procs = open(cmd, "r", devnull) + procs = open(cmd, "r", DevNull) bytes = read(procs.out) success(procs) || pipeline_error(procs) return bytes @@ -660,7 +660,7 @@ including the process exiting with a non-zero status (when `wait` is true). If `wait` is false, the process runs asynchronously. You can later wait for it and check its exit status by calling `success` on the returned process object. -When `wait` is false, the process' I/O streams are directed to `devnull`. +When `wait` is false, the process' I/O streams are directed to `DevNull`. When `wait` is true, I/O streams are shared with the parent process. Use [`pipeline`](@ref) to control I/O redirection. """ diff --git a/base/show.jl b/base/show.jl index c51d5b279c2d3..3fda723edc7f4 100644 --- a/base/show.jl +++ b/base/show.jl @@ -247,9 +247,9 @@ julia> String(take!(io)) ``` ```jldoctest -julia> print(IOContext(stdout, :compact => false), 1.12341234) +julia> print(IOContext(STDOUT, :compact => false), 1.12341234) 1.12341234 -julia> print(IOContext(stdout, :compact => true), 1.12341234) +julia> print(IOContext(STDOUT, :compact => true), 1.12341234) 1.12341 ``` @@ -263,9 +263,9 @@ julia> function f(io::IO) end f (generic function with 1 method) -julia> f(stdout) +julia> f(STDOUT) loooooong -julia> f(IOContext(stdout, :short => true)) +julia> f(IOContext(STDOUT, :short => true)) short ``` """ @@ -311,7 +311,7 @@ Write an informative text representation of a value to the current output stream should overload `show(io, x)` where the first argument is a stream. The representation used by `show` generally includes Julia-specific formatting and type information. """ -show(x) = show(stdout::IO, x) +show(x) = show(STDOUT::IO, x) show(io::IO, @nospecialize(x)) = show_default(io, x) @@ -535,7 +535,7 @@ function show_supertypes(io::IO, typ::DataType) end end -show_supertypes(typ::DataType) = show_supertypes(stdout, typ) +show_supertypes(typ::DataType) = show_supertypes(STDOUT, typ) """ @show @@ -1762,7 +1762,7 @@ DeeplyNested 1: DeeplyNested ``` """ -dump(arg; maxdepth=DUMP_DEFAULT_MAXDEPTH) = dump(IOContext(stdout::IO, :limit => true), arg; maxdepth=maxdepth) +dump(arg; maxdepth=DUMP_DEFAULT_MAXDEPTH) = dump(IOContext(STDOUT::IO, :limit => true), arg; maxdepth=maxdepth) """ @@ -1961,8 +1961,8 @@ function print_bit_chunk(io::IO, c::UInt64, l::Integer = 64) end end -print_bit_chunk(c::UInt64, l::Integer) = print_bit_chunk(stdout, c, l) -print_bit_chunk(c::UInt64) = print_bit_chunk(stdout, c) +print_bit_chunk(c::UInt64, l::Integer) = print_bit_chunk(STDOUT, c, l) +print_bit_chunk(c::UInt64) = print_bit_chunk(STDOUT, c) function bitshow(io::IO, B::BitArray) isempty(B) && return @@ -1974,6 +1974,6 @@ function bitshow(io::IO, B::BitArray) l = _mod64(length(B)-1) + 1 print_bit_chunk(io, Bc[end], l) end -bitshow(B::BitArray) = bitshow(stdout, B) +bitshow(B::BitArray) = bitshow(STDOUT, B) bitstring(B::BitArray) = sprint(bitshow, B) diff --git a/base/stream.jl b/base/stream.jl index 4f3488e1804f3..8727be7db3add 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -372,7 +372,7 @@ julia> withenv("LINES" => 30, "COLUMNS" => 100) do To get your TTY size, ```julia -julia> displaysize(stdout) +julia> displaysize(STDOUT) (34, 147) ``` """ @@ -906,22 +906,21 @@ function _fd(x::Union{LibuvStream, LibuvServer}) end for (x, writable, unix_fd, c_symbol) in - ((:stdin, false, 0, :jl_uv_stdin), - (:stdout, true, 1, :jl_uv_stdout), - (:stderr, true, 2, :jl_uv_stderr)) + ((:STDIN, false, 0, :jl_uv_stdin), + (:STDOUT, true, 1, :jl_uv_stdout), + (:STDERR, true, 2, :jl_uv_stderr)) f = Symbol("redirect_", lowercase(string(x))) _f = Symbol("_", f) - Ux = Symbol(uppercase(string(x))) @eval begin function ($_f)(stream) - global $x, $Ux + global $x posix_fd = _fd(stream) @static if Sys.iswindows() ccall(:SetStdHandle, stdcall, Int32, (Int32, OS_HANDLE), $(-10 - unix_fd), Libc._get_osfhandle(posix_fd)) end dup(posix_fd, RawFD($unix_fd)) - $Ux = $x = stream + $x = stream nothing end function ($f)(handle::Union{LibuvStream, IOStream}) @@ -942,12 +941,12 @@ end """ redirect_stdout([stream]) -> (rd, wr) -Create a pipe to which all C and Julia level [`stdout`](@ref) output +Create a pipe to which all C and Julia level [`STDOUT`](@ref) output will be redirected. Returns a tuple `(rd, wr)` representing the pipe ends. -Data written to [`stdout`](@ref) may now be read from the `rd` end of +Data written to [`STDOUT`](@ref) may now be read from the `rd` end of the pipe. The `wr` end is given for convenience in case the old -[`stdout`](@ref) object was cached by the user and needs to be replaced +[`STDOUT`](@ref) object was cached by the user and needs to be replaced elsewhere. !!! note @@ -958,7 +957,7 @@ redirect_stdout """ redirect_stderr([stream]) -> (rd, wr) -Like [`redirect_stdout`](@ref), but for [`stderr`](@ref). +Like [`redirect_stdout`](@ref), but for [`STDERR`](@ref). !!! note `stream` must be a `TTY`, a `Pipe`, or a socket. @@ -968,16 +967,16 @@ redirect_stderr """ redirect_stdin([stream]) -> (rd, wr) -Like [`redirect_stdout`](@ref), but for [`stdin`](@ref). +Like [`redirect_stdout`](@ref), but for [`STDIN`](@ref). Note that the order of the return tuple is still `(rd, wr)`, -i.e. data to be read from [`stdin`](@ref) may be written to `wr`. +i.e. data to be read from [`STDIN`](@ref) may be written to `wr`. !!! note `stream` must be a `TTY`, a `Pipe`, or a socket. """ redirect_stdin -for (F,S) in ((:redirect_stdin, :stdin), (:redirect_stdout, :stdout), (:redirect_stderr, :stderr)) +for (F,S) in ((:redirect_stdin, :STDIN), (:redirect_stdout, :STDOUT), (:redirect_stderr, :STDERR)) @eval function $F(f::Function, stream) STDOLD = $S local ret @@ -994,8 +993,8 @@ end """ redirect_stdout(f::Function, stream) -Run the function `f` while redirecting [`stdout`](@ref) to `stream`. -Upon completion, [`stdout`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`STDOUT`](@ref) to `stream`. +Upon completion, [`STDOUT`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a socket. @@ -1005,8 +1004,8 @@ redirect_stdout(f::Function, stream) """ redirect_stderr(f::Function, stream) -Run the function `f` while redirecting [`stderr`](@ref) to `stream`. -Upon completion, [`stderr`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`STDERR`](@ref) to `stream`. +Upon completion, [`STDERR`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a socket. @@ -1016,8 +1015,8 @@ redirect_stderr(f::Function, stream) """ redirect_stdin(f::Function, stream) -Run the function `f` while redirecting [`stdin`](@ref) to `stream`. -Upon completion, [`stdin`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`STDIN`](@ref) to `stream`. +Upon completion, [`STDIN`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a socket. diff --git a/base/strings/io.jl b/base/strings/io.jl index 97d43f4e0282d..3172c6f83e252 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -5,7 +5,7 @@ """ print([io::IO], xs...) -Write to `io` (or to the default output stream [`stdout`](@ref) +Write to `io` (or to the default output stream [`STDOUT`](@ref) if `io` is not given) a canonical (un-decorated) text representation of values `xs` if there is one, otherwise call [`show`](@ref). The representation used by `print` includes minimal formatting and tries to @@ -49,7 +49,7 @@ end println([io::IO], xs...) Print (using [`print`](@ref)) `xs` followed by a newline. -If `io` is not supplied, prints to [`stdout`](@ref). +If `io` is not supplied, prints to [`STDOUT`](@ref). # Examples ```jldoctest diff --git a/base/sysimg.jl b/base/sysimg.jl index f057ce998b121..f8e8ad997775c 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -922,12 +922,12 @@ tot_time = tot_time_base + Base.tot_time_stdlib[] + tot_time_userimg + tot_time_ println("Sysimage built. Summary:") print("Total ─────── "); Base.time_print(tot_time * 10^9); print(" \n"); -print("Base: ─────── "); Base.time_print(tot_time_base * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (tot_time_base / tot_time) * 100); println("%") -print("Stdlibs: ──── "); Base.time_print(Base.tot_time_stdlib[] * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (Base.tot_time_stdlib[] / tot_time) * 100); println("%") +print("Base: ─────── "); Base.time_print(tot_time_base * 10^9); print(" "); show(IOContext(STDOUT, :compact=>true), (tot_time_base / tot_time) * 100); println("%") +print("Stdlibs: ──── "); Base.time_print(Base.tot_time_stdlib[] * 10^9); print(" "); show(IOContext(STDOUT, :compact=>true), (Base.tot_time_stdlib[] / tot_time) * 100); println("%") if isfile("userimg.jl") -print("Userimg: ──── "); Base.time_print(tot_time_userimg * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (tot_time_userimg / tot_time) * 100); println("%") +print("Userimg: ──── "); Base.time_print(tot_time_userimg * 10^9); print(" "); show(IOContext(STDOUT, :compact=>true), (tot_time_userimg / tot_time) * 100); println("%") end -print("Precompile: ─ "); Base.time_print(tot_time_precompile * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (tot_time_precompile / tot_time) * 100); println("%") +print("Precompile: ─ "); Base.time_print(tot_time_precompile * 10^9); print(" "); show(IOContext(STDOUT, :compact=>true), (tot_time_precompile / tot_time) * 100); println("%") end empty!(LOAD_PATH) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 0fc791a946557..1aebaab11eb2f 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -81,7 +81,7 @@ function __init__() global CPU_CORES = if !isempty(env_cores) env_cores = tryparse(Int, env_cores) if !(env_cores isa Int && env_cores > 0) - Core.print(Core.stderr, "WARNING: couldn't parse `JULIA_CPU_CORES` environment variable. Defaulting Sys.CPU_CORES to 1.\n") + Core.print(Core.STDERR, "WARNING: couldn't parse `JULIA_CPU_CORES` environment variable. Defaulting Sys.CPU_CORES to 1.\n") env_cores = 1 end env_cores @@ -165,7 +165,7 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) println(io) end -function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) +function cpu_summary(io::IO=STDOUT, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model first = 1 for i = 2:length(cpu) diff --git a/base/task.jl b/base/task.jl index 9c89a78165c3a..d14f9bd7764d4 100644 --- a/base/task.jl +++ b/base/task.jl @@ -238,7 +238,7 @@ function task_done_hook(t::Task) if !suppress_excp_printing(t) let bt = t.backtrace # run a new task to print the error for us - @schedule with_output_color(Base.error_color(), stderr) do io + @schedule with_output_color(Base.error_color(), STDERR) do io print(io, "ERROR (unhandled task failure): ") showerror(io, result, bt) println(io) diff --git a/base/util.jl b/base/util.jl index ddadd50f347b9..097875fa6ed98 100644 --- a/base/util.jl +++ b/base/util.jl @@ -334,7 +334,7 @@ If the keyword `bold` is given as `true`, the result will be printed in bold. printstyled(io::IO, msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = with_output_color(print, color, io, msg...; bold=bold) printstyled(msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = - printstyled(stdout, msg...; bold=bold, color=color) + printstyled(STDOUT, msg...; bold=bold, color=color) function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename())) opts = JLOptions() @@ -385,7 +385,7 @@ unsafe_securezero!(p::Ptr{Cvoid}, len::Integer=1) = Ptr{Cvoid}(unsafe_securezero if Sys.iswindows() function getpass(prompt::AbstractString) print(prompt) - flush(stdout) + flush(STDOUT) p = Vector{UInt8}(undef, 128) # mimic Unix getpass in ignoring more than 128-char passwords # (also avoids any potential memory copies arising from push!) try diff --git a/base/version.jl b/base/version.jl index 0ba3ba9575336..d6b987fa9c352 100644 --- a/base/version.jl +++ b/base/version.jl @@ -233,7 +233,7 @@ end const libllvm_version = VersionNumber(libllvm_version_string) -function banner(io::IO = stdout) +function banner(io::IO = STDOUT) if GIT_VERSION_INFO.tagged_commit commit_string = TAGGED_RELEASE_BANNER elseif isempty(GIT_VERSION_INFO.commit) diff --git a/contrib/build_sysimg.jl b/contrib/build_sysimg.jl index 9ca9bdb133230..e57a5a27c8f0f 100644 --- a/contrib/build_sysimg.jl +++ b/contrib/build_sysimg.jl @@ -168,7 +168,7 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false info("$cc $(join(FLAGS, ' ')) -o $sysimg_file $sysimg_path.o") # Windows has difficulties overwriting a file in use so we first link to a temp file if Sys.iswindows() && isfile(sysimg_file) - if success(pipeline(`$cc $FLAGS -o $sysimg_path.tmp $sysimg_path.o`; stdout=stdout, stderr=stderr)) + if success(pipeline(`$cc $FLAGS -o $sysimg_path.tmp $sysimg_path.o`; stdout=STDOUT, stderr=STDERR)) mv(sysimg_file, "$sysimg_file.old"; force=true) mv("$sysimg_path.tmp", sysimg_file; force=true) end diff --git a/contrib/julia-config.jl b/contrib/julia-config.jl index 8ac742fade6c1..1ccdd3b2fa720 100755 --- a/contrib/julia-config.jl +++ b/contrib/julia-config.jl @@ -75,7 +75,7 @@ end function check_args(args) checked = intersect(args, options) if length(checked) == 0 || length(checked) != length(args) - println(stderr, "Usage: julia-config [", join(options, " | "), "]") + println(STDERR, "Usage: julia-config [", join(options, " | "), "]") exit(1) end end diff --git a/doc/src/base/base.md b/doc/src/base/base.md index f9a8354b90229..ff67015e40d85 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -228,7 +228,7 @@ Base.skipmissing ```@docs Base.run -Base.devnull +Base.DevNull Base.success Base.process_running Base.process_exited diff --git a/doc/src/base/constants.md b/doc/src/base/constants.md index b56659e77f302..0f4c321d69067 100644 --- a/doc/src/base/constants.md +++ b/doc/src/base/constants.md @@ -17,9 +17,9 @@ Base.Sys.MACHINE See also: - * [`stdin`](@ref) - * [`stdout`](@ref) - * [`stderr`](@ref) + * [`STDIN`](@ref) + * [`STDOUT`](@ref) + * [`STDERR`](@ref) * [`ENV`](@ref) * [`ENDIAN_BOM`](@ref) * `Libc.MS_ASYNC` diff --git a/doc/src/base/io-network.md b/doc/src/base/io-network.md index 377ee41c5bf6a..8b029b67ee757 100644 --- a/doc/src/base/io-network.md +++ b/doc/src/base/io-network.md @@ -3,9 +3,9 @@ ## General I/O ```@docs -Base.stdout -Base.stderr -Base.stdin +Base.STDOUT +Base.STDERR +Base.STDIN Base.open Base.IOBuffer Base.take!(::Base.GenericIOBuffer) diff --git a/doc/src/devdocs/stdio.md b/doc/src/devdocs/stdio.md index d17f7abc06bb9..2adc259e03640 100644 --- a/doc/src/devdocs/stdio.md +++ b/doc/src/devdocs/stdio.md @@ -29,24 +29,24 @@ void jl_safe_printf(const char *str, ...); ## Interface between JL_STD* and Julia code -[`Base.stdin`](@ref), [`Base.stdout`](@ref) and [`Base.stderr`](@ref) are bound to the `JL_STD*` libuv +[`Base.STDIN`](@ref), [`Base.STDOUT`](@ref) and [`Base.STDERR`](@ref) are bound to the `JL_STD*` libuv streams defined in the runtime. Julia's `__init__()` function (in `base/sysimg.jl`) calls `reinit_stdio()` (in `base/stream.jl`) -to create Julia objects for [`Base.stdin`](@ref), [`Base.stdout`](@ref) and [`Base.stderr`](@ref). +to create Julia objects for [`Base.STDIN`](@ref), [`Base.STDOUT`](@ref) and [`Base.STDERR`](@ref). `reinit_stdio()` uses [`ccall`](@ref) to retrieve pointers to `JL_STD*` and calls `jl_uv_handle_type()` to inspect the type of each stream. It then creates a Julia `Base.IOStream`, `Base.TTY` or `Base.PipeEndpoint` object to represent each stream, e.g.: ``` -$ julia -e 'println(typeof((stdin, stdout, stderr)))' +$ julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' Tuple{Base.TTY,Base.TTY,Base.TTY} -$ julia -e 'println(typeof((stdin, stdout, stderr)))' < /dev/null 2>/dev/null +$ julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' < /dev/null 2>/dev/null Tuple{IOStream,Base.TTY,IOStream} -$ echo hello | julia -e 'println(typeof((stdin, stdout, stderr)))' | cat +$ echo hello | julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' | cat Tuple{Base.PipeEndpoint,Base.PipeEndpoint,Base.TTY} ``` diff --git a/doc/src/manual/faq.md b/doc/src/manual/faq.md index da681180598be..2dccc2a0da3d5 100644 --- a/doc/src/manual/faq.md +++ b/doc/src/manual/faq.md @@ -693,7 +693,7 @@ Consider the printed output from the following: ```jldoctest julia> @sync for i in 1:3 - @async write(stdout, string(i), " Foo ", " Bar ") + @async write(STDOUT, string(i), " Foo ", " Bar ") end 123 Foo Foo Foo Bar Bar Bar ``` @@ -706,7 +706,7 @@ in the above example results in: ```jldoctest julia> @sync for i in 1:3 - @async println(stdout, string(i), " Foo ", " Bar ") + @async println(STDOUT, string(i), " Foo ", " Bar ") end 1 Foo Bar 2 Foo Bar @@ -723,7 +723,7 @@ julia> @sync for i in 1:3 @async begin lock(l) try - write(stdout, string(i), " Foo ", " Bar ") + write(STDOUT, string(i), " Foo ", " Bar ") finally unlock(l) end diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index 20930e2a3210b..2b5c1099e84ad 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -343,11 +343,11 @@ Other known potential failure scenarios include: of via its lookup path. For example, (in global scope): ```julia - #mystdout = Base.stdout #= will not work correctly, since this will copy Base.stdout into this module =# + #mystdout = Base.STDOUT #= will not work correctly, since this will copy Base.STDOUT into this module =# # instead use accessor functions: - getstdout() = Base.stdout #= best option =# + getstdout() = Base.STDOUT #= best option =# # or move the assignment into the runtime: - __init__() = global mystdout = Base.stdout #= also works =# + __init__() = global mystdout = Base.STDOUT #= also works =# ``` Several additional restrictions are placed on the operations that can be done while precompiling diff --git a/doc/src/manual/networking-and-streams.md b/doc/src/manual/networking-and-streams.md index 51b691255c9f7..f48bb355b130c 100644 --- a/doc/src/manual/networking-and-streams.md +++ b/doc/src/manual/networking-and-streams.md @@ -12,14 +12,14 @@ All Julia streams expose at least a [`read`](@ref) and a [`write`](@ref) method, stream as their first argument, e.g.: ```julia-repl -julia> write(stdout, "Hello World"); # suppress return value 11 with ; +julia> write(STDOUT, "Hello World"); # suppress return value 11 with ; Hello World -julia> read(stdin, Char) +julia> read(STDIN, Char) '\n': ASCII/Unicode U+000a (category Cc: Other, control) ``` -Note that [`write`](@ref) returns 11, the number of bytes (in `"Hello World"`) written to [`stdout`](@ref), +Note that [`write`](@ref) returns 11, the number of bytes (in `"Hello World"`) written to [`STDOUT`](@ref), but this return value is suppressed with the `;`. Here Enter was pressed again so that Julia would read the newline. Now, as you can see from this @@ -36,7 +36,7 @@ julia> x = zeros(UInt8, 4) 0x00 0x00 -julia> read!(stdin, x) +julia> read!(STDIN, x) abcd 4-element Array{UInt8,1}: 0x61 @@ -49,7 +49,7 @@ However, since this is slightly cumbersome, there are several convenience method example, we could have written the above as: ```julia-repl -julia> read(stdin, 4) +julia> read(STDIN, 4) abcd 4-element Array{UInt8,1}: 0x61 @@ -61,7 +61,7 @@ abcd or if we had wanted to read the entire line instead: ```julia-repl -julia> readline(stdin) +julia> readline(STDIN) abcd "abcd" ``` @@ -69,10 +69,10 @@ abcd Note that depending on your terminal settings, your TTY may be line buffered and might thus require an additional enter before the data is sent to Julia. -To read every line from [`stdin`](@ref) you can use [`eachline`](@ref): +To read every line from [`STDIN`](@ref) you can use [`eachline`](@ref): ```julia -for line in eachline(stdin) +for line in eachline(STDIN) print("Found $line") end ``` @@ -80,8 +80,8 @@ end or [`read`](@ref) if you wanted to read by character instead: ```julia -while !eof(stdin) - x = read(stdin, Char) +while !eof(STDIN) + x = read(STDIN, Char) println("Found: $x") end ``` @@ -92,18 +92,18 @@ Note that the [`write`](@ref) method mentioned above operates on binary streams. values do not get converted to any canonical text representation but are written out as is: ```jldoctest -julia> write(stdout, 0x61); # suppress return value 1 with ; +julia> write(STDOUT, 0x61); # suppress return value 1 with ; a ``` -Note that `a` is written to [`stdout`](@ref) by the [`write`](@ref) function and that the returned +Note that `a` is written to [`STDOUT`](@ref) by the [`write`](@ref) function and that the returned value is `1` (since `0x61` is one byte). For text I/O, use the [`print`](@ref) or [`show`](@ref) methods, depending on your needs (see the documentation for these two methods for a detailed discussion of the difference between them): ```jldoctest -julia> print(stdout, 0x61) +julia> print(STDOUT, 0x61) 97 ``` @@ -276,7 +276,7 @@ julia> clientside = connect(2001) TCPSocket(RawFD(28) open, 0 bytes waiting) julia> @async while true - write(stdout,readline(clientside)) + write(STDOUT,readline(clientside)) end Task (runnable) @0x00007fd31dc11870 diff --git a/doc/src/manual/parallel-computing.md b/doc/src/manual/parallel-computing.md index 58bdaf9f72de0..c0bbbd2c0dbd1 100644 --- a/doc/src/manual/parallel-computing.md +++ b/doc/src/manual/parallel-computing.md @@ -1072,8 +1072,8 @@ manner: * [`addprocs`](@ref) is called on the master process with a `ClusterManager` object. * [`addprocs`](@ref) calls the appropriate [`launch`](@ref) method which spawns required number of worker processes on appropriate machines. - * Each worker starts listening on a free port and writes out its host and port information to [`stdout`](@ref). - * The cluster manager captures the [`stdout`](@ref) of each worker and makes it available to the + * Each worker starts listening on a free port and writes out its host and port information to [`STDOUT`](@ref). + * The cluster manager captures the [`STDOUT`](@ref) of each worker and makes it available to the master process. * The master process parses this information and sets up TCP/IP connections to each worker. * Every worker is also notified of other workers in the cluster. @@ -1317,7 +1317,7 @@ on the master process: are allowed to connect to each other. * The cookie may be passed to the workers at startup via argument `--worker=`. If argument `--worker` is specified without the cookie, the worker tries to read the cookie from its - standard input ([`stdin`](@ref)). The `stdin` is closed immediately after the cookie is retrieved. + standard input ([`STDIN`](@ref)). The `STDIN` is closed immediately after the cookie is retrieved. * `ClusterManager`s can retrieve the cookie on the master by calling [`cluster_cookie()`](@ref). Cluster managers not using the default TCP/IP transport (and hence not specifying `--worker`) must call `init_worker(cookie, manager)` with the same cookie as on the master. diff --git a/doc/src/manual/profile.md b/doc/src/manual/profile.md index 00d91cf5f0d7c..29cda5c48782f 100644 --- a/doc/src/manual/profile.md +++ b/doc/src/manual/profile.md @@ -210,12 +210,12 @@ be very useful, but sometimes you want to start fresh; you can do so with [`Prof [`Profile.print`](@ref) has more options than we've described so far. Let's see the full declaration: ```julia -function print(io::IO = stdout, data = fetch(); kwargs...) +function print(io::IO = STDOUT, data = fetch(); kwargs...) ``` Let's first discuss the two positional arguments, and later the keyword arguments: - * `io` -- Allows you to save the results to a buffer, e.g. a file, but the default is to print to `stdout` + * `io` -- Allows you to save the results to a buffer, e.g. a file, but the default is to print to `STDOUT` (the console). * `data` -- Contains the data you want to analyze; by default that is obtained from [`Profile.fetch()`](@ref), which pulls out the backtraces from a pre-allocated buffer. For example, if you want to profile @@ -224,7 +224,7 @@ Let's first discuss the two positional arguments, and later the keyword argument ```julia data = copy(Profile.fetch()) Profile.clear() - @profile Profile.print(stdout, data) # Prints the previous results + @profile Profile.print(STDOUT, data) # Prints the previous results Profile.print() # Prints results from Profile.print() ``` diff --git a/doc/src/manual/running-external-programs.md b/doc/src/manual/running-external-programs.md index 749d88b75f2cf..19ba75e77b580 100644 --- a/doc/src/manual/running-external-programs.md +++ b/doc/src/manual/running-external-programs.md @@ -14,7 +14,7 @@ differs in several aspects from the behavior in various shells, Perl, or Ruby: You can use this object to connect the command to others via pipes, [`run`](@ref) it, and [`read`](@ref) or [`write`](@ref) to it. * When the command is run, Julia does not capture its output unless you specifically arrange for - it to. Instead, the output of the command by default goes to [`stdout`](@ref) as it would using + it to. Instead, the output of the command by default goes to [`STDOUT`](@ref) as it would using `libc`'s `system` call. * The command is never run with a shell. Instead, Julia parses the command syntax directly, appropriately interpolating variables and splitting on words as the shell would, respecting shell quoting syntax. @@ -33,7 +33,7 @@ julia> run(mycommand); hello ``` -The `hello` is the output of the `echo` command, sent to [`stdout`](@ref). The run method itself +The `hello` is the output of the `echo` command, sent to [`STDOUT`](@ref). The run method itself returns `nothing`, and throws an [`ErrorException`](@ref) if the external command fails to run successfully. @@ -50,7 +50,7 @@ true More generally, you can use [`open`](@ref) to read from or write to an external command. ```jldoctest -julia> open(`less`, "w", stdout) do io +julia> open(`less`, "w", STDOUT) do io for i = 1:3 println(io, i) end @@ -280,7 +280,7 @@ hello ``` The order of the output here is non-deterministic because the two `echo` processes are started -nearly simultaneously, and race to make the first write to the [`stdout`](@ref) descriptor they +nearly simultaneously, and race to make the first write to the [`STDOUT`](@ref) descriptor they share with each other and the `julia` parent process. Julia lets you pipe the output from both of these processes to another program: @@ -343,7 +343,7 @@ generates lines with the numbers 0 through 5 on them, while two parallel process output, one prefixing lines with the letter "A", the other with the letter "B". Which consumer gets the first line is non-deterministic, but once that race has been won, the lines are consumed alternately by one process and then the other. (Setting `$|=1` in Perl causes each print statement -to flush the [`stdout`](@ref) handle, which is necessary for this example to work. Otherwise all +to flush the [`STDOUT`](@ref) handle, which is necessary for this example to work. Otherwise all the output is buffered and printed to the pipe at once, to be read by just one consumer process.) Here is an even more complex multi-stage producer-consumer example: diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index 1a7d849ae1a7a..5cb6c38fd2be3 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -1250,8 +1250,8 @@ julia> [Polar(3, 4.0), Polar(4.0,5.3)] ``` where the single-line `show(io, z)` form is still used for an array of `Polar` values. Technically, -the REPL calls `display(z)` to display the result of executing a line, which defaults to `show(stdout, MIME("text/plain"), z)`, -which in turn defaults to `show(stdout, z)`, but you should *not* define new [`display`](@ref) +the REPL calls `display(z)` to display the result of executing a line, which defaults to `show(STDOUT, MIME("text/plain"), z)`, +which in turn defaults to `show(STDOUT, z)`, but you should *not* define new [`display`](@ref) methods unless you are defining a new multimedia display handler (see [Multimedia I/O](@ref)). Moreover, you can also define `show` methods for other MIME types in order to enable richer display @@ -1268,7 +1268,7 @@ A `Polar` object will then display automatically using HTML in an environment th display, but you can call `show` manually to get HTML output if you want: ```jldoctest polartype -julia> show(stdout, "text/html", Polar(3.0,4.0)) +julia> show(STDOUT, "text/html", Polar(3.0,4.0)) Polar{Float64} complex number: 3.0 e4.0 i ``` diff --git a/src/rtutils.c b/src/rtutils.c index 22a1e8b1fa5ad..36eb8b611930a 100644 --- a/src/rtutils.c +++ b/src/rtutils.c @@ -471,14 +471,14 @@ JL_DLLEXPORT void jl_flush_cstdio(void) JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) { if (jl_base_module == NULL) return NULL; - jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("stdout")); + jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("STDOUT")); return stdout_obj; } JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) { if (jl_base_module == NULL) return NULL; - jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("stderr")); + jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("STDERR")); return stderr_obj; } diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index a5792ca174077..9c3730c87e185 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -173,24 +173,24 @@ worker_timeout() = parse(Float64, get(ENV, "JULIA_WORKER_TIMEOUT", "60.0")) ## worker creation and setup ## """ - start_worker([out::IO=stdout], cookie::AbstractString=readline(stdin)) + start_worker([out::IO=STDOUT], cookie::AbstractString=readline(STDIN)) `start_worker` is an internal function which is the default entry point for worker processes connecting via TCP/IP. It sets up the process as a Julia cluster worker. -host:port information is written to stream `out` (defaults to stdout). +host:port information is written to stream `out` (defaults to STDOUT). -The function closes stdin (after reading the cookie if required), redirects stderr to stdout, +The function closes STDIN (after reading the cookie if required), redirects STDERR to STDOUT, listens on a free port (or if specified, the port in the `--bind-to` command line option) and schedules tasks to process incoming TCP connections and requests. It does not return. """ -start_worker(cookie::AbstractString=readline(stdin)) = start_worker(stdout, cookie) -function start_worker(out::IO, cookie::AbstractString=readline(stdin)) - close(stdin) # workers will not use it - redirect_stderr(stdout) +start_worker(cookie::AbstractString=readline(STDIN)) = start_worker(STDOUT, cookie) +function start_worker(out::IO, cookie::AbstractString=readline(STDIN)) + close(STDIN) # workers will not use it + redirect_stderr(STDOUT) init_worker(cookie) interface = IPv4(LPROC.bind_addr) @@ -223,7 +223,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(stdin)) check_master_connect() while true; wait(); end catch err - print(stderr, "unhandled exception on $(myid()): $(err)\nexiting.\n") + print(STDERR, "unhandled exception on $(myid()): $(err)\nexiting.\n") end close(sock) @@ -235,8 +235,8 @@ function redirect_worker_output(ident, stream) @schedule while !eof(stream) line = readline(stream) if startswith(line, " From worker ") - # stdout's of "additional" workers started from an initial worker on a host are not available - # on the master directly - they are routed via the initial worker's stdout. + # STDOUT's of "additional" workers started from an initial worker on a host are not available + # on the master directly - they are routed via the initial worker's STDOUT. println(line) else println(" From worker $(ident):\t$line") @@ -629,7 +629,7 @@ function check_master_connect() end if !haskey(map_pid_wrkr, 1) - print(stderr, "Master process (id 1) could not connect within $timeout seconds.\nexiting.\n") + print(STDERR, "Master process (id 1) could not connect within $timeout seconds.\nexiting.\n") exit(1) end end diff --git a/stdlib/Distributed/src/managers.jl b/stdlib/Distributed/src/managers.jl index 7e1235a5c83b2..c96be61308d82 100644 --- a/stdlib/Distributed/src/managers.jl +++ b/stdlib/Distributed/src/managers.jl @@ -129,7 +129,7 @@ function launch(manager::SSHManager, params::Dict, launched::Array, launch_ntfy: launch_tasks[i] = @schedule try launch_on_machine(manager, machine, cnt, params, launched, launch_ntfy) catch e - print(stderr, "exception launching on machine $(machine) : $(e)\n") + print(STDERR, "exception launching on machine $(machine) : $(e)\n") end end end diff --git a/stdlib/Distributed/src/messages.jl b/stdlib/Distributed/src/messages.jl index 48dccebce55a0..091fdfd7e8936 100644 --- a/stdlib/Distributed/src/messages.jl +++ b/stdlib/Distributed/src/messages.jl @@ -201,7 +201,7 @@ function flush_gc_msgs() end catch e bt = catch_backtrace() - @schedule showerror(stderr, e, bt) + @schedule showerror(STDERR, e, bt) end end diff --git a/stdlib/Distributed/src/process_messages.jl b/stdlib/Distributed/src/process_messages.jl index 079646d89ff8d..6b5efdb1c6617 100644 --- a/stdlib/Distributed/src/process_messages.jl +++ b/stdlib/Distributed/src/process_messages.jl @@ -57,7 +57,7 @@ function run_work_thunk(thunk, print_error) catch err ce = CapturedException(err, catch_backtrace()) result = RemoteException(ce) - print_error && showerror(stderr, ce) + print_error && showerror(STDERR, ce) end return result end @@ -200,8 +200,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) end if wpid < 1 - println(stderr, e, CapturedException(e, catch_backtrace())) - println(stderr, "Process($(myid())) - Unknown remote, closing connection.") + println(STDERR, e, CapturedException(e, catch_backtrace())) + println(STDERR, "Process($(myid())) - Unknown remote, closing connection.") elseif !(wpid in map_del_wrkr) werr = worker_from_id(wpid) oldstate = werr.state @@ -226,7 +226,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) if (myid() == 1) && (wpid > 1) if oldstate != W_TERMINATING - println(stderr, "Worker $wpid terminated.") + println(STDERR, "Worker $wpid terminated.") rethrow(e) end end diff --git a/stdlib/Distributed/src/remotecall.jl b/stdlib/Distributed/src/remotecall.jl index bf162a180a512..f86f9da8a38fc 100644 --- a/stdlib/Distributed/src/remotecall.jl +++ b/stdlib/Distributed/src/remotecall.jl @@ -450,7 +450,7 @@ invoked, the order of executions on the remote worker is undetermined. For examp to `f1`, followed by `f2` and `f3` in that order. However, it is not guaranteed that `f1` is executed before `f3` on worker 2. -Any exceptions thrown by `f` are printed to [`stderr`](@ref) on the remote worker. +Any exceptions thrown by `f` are printed to [`STDERR`](@ref) on the remote worker. Keyword arguments, if any, are passed through to `f`. """ diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index a5678c1d32e40..c2d7c3198384b 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1056,8 +1056,8 @@ end # Test the following addprocs error conditions # - invalid host name - github issue #20372 # - julia exe exiting with an error -# - timeout reading host:port from worker stdout -# - host:port not found in worker stdout in the first 1000 lines +# - timeout reading host:port from worker STDOUT +# - host:port not found in worker STDOUT in the first 1000 lines struct ErrorSimulator <: ClusterManager mode @@ -1099,7 +1099,7 @@ append!(testruns, [ ]) for (addp_testf, expected_errstr, env) in testruns - old_stdout = stdout + old_stdout = STDOUT stdout_out, stdout_in = redirect_stdout() stdout_txt = @schedule filter!(readlines(stdout_out)) do s return !startswith(s, "\tFrom failed worker startup:\t") diff --git a/stdlib/Distributed/test/runtests.jl b/stdlib/Distributed/test/runtests.jl index 4ab1b69739840..1683944a42a25 100644 --- a/stdlib/Distributed/test/runtests.jl +++ b/stdlib/Distributed/test/runtests.jl @@ -7,6 +7,6 @@ disttestfile = joinpath(@__DIR__, "distributed_exec.jl") cmd = `$test_exename $test_exeflags $disttestfile` -if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 +if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 error("Distributed test failed, cmd : $cmd") end diff --git a/stdlib/InteractiveUtils/src/InteractiveUtils.jl b/stdlib/InteractiveUtils/src/InteractiveUtils.jl index 0c82391ead01e..8f0d0b97d770b 100644 --- a/stdlib/InteractiveUtils/src/InteractiveUtils.jl +++ b/stdlib/InteractiveUtils/src/InteractiveUtils.jl @@ -45,7 +45,7 @@ end varinfo(pat::Regex) = varinfo(Main, pat) """ - versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false) + versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false) Print information about the version of Julia in use. The output is controlled with boolean keyword arguments: @@ -53,7 +53,7 @@ controlled with boolean keyword arguments: - `packages`: print information about installed packages - `verbose`: print all additional information """ -function versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false) +function versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false) println(io, "Julia Version $VERSION") if !isempty(Base.GIT_VERSION_INFO.commit_short) println(io, "Commit $(Base.GIT_VERSION_INFO.commit_short) ($(Base.GIT_VERSION_INFO.date_string))") @@ -68,7 +68,7 @@ function versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false) if verbose lsb = "" if Sys.islinux() - try lsb = readchomp(pipeline(`lsb_release -ds`, stderr=devnull)) end + try lsb = readchomp(pipeline(`lsb_release -ds`, stderr=DevNull)) end end if Sys.iswindows() try lsb = strip(read(`$(ENV["COMSPEC"]) /c ver`, String)) end diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index 1983c95dc9366..f67fc2bba4970 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -6,7 +6,7 @@ code_warntype([io::IO], f, types) Prints lowered and type-inferred ASTs for the methods matching the given generic function -and type signature to `io` which defaults to `stdout`. The ASTs are annotated in such a way +and type signature to `io` which defaults to `STDOUT`. The ASTs are annotated in such a way as to cause "non-leaf" types to be emphasized (if color is available, displayed in red). This serves as a warning of potential type instability. Not all non-leaf types are particularly problematic for performance, so the results need to be used judiciously. @@ -58,7 +58,7 @@ function code_warntype(io::IO, f, @nospecialize(t)) end nothing end -code_warntype(f, @nospecialize(t)) = code_warntype(stdout, f, t) +code_warntype(f, @nospecialize(t)) = code_warntype(STDOUT, f, t) import Base.CodegenParams @@ -111,7 +111,7 @@ function _dump_function_linfo(linfo::Core.MethodInstance, world::UInt, native::B end """ - code_llvm([io=stdout,], f, types) + code_llvm([io=STDOUT,], f, types) Prints the LLVM bitcodes generated for running the method matching the given generic function and type signature to `io`. @@ -120,11 +120,11 @@ All metadata and dbg.* calls are removed from the printed bitcode. Use `code_llv """ code_llvm(io::IO, @nospecialize(f), @nospecialize(types=Tuple), strip_ir_metadata=true, dump_module=false) = print(io, _dump_function(f, types, false, false, strip_ir_metadata, dump_module)) -code_llvm(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(stdout, f, types) -code_llvm_raw(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(stdout, f, types, false) +code_llvm(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(STDOUT, f, types) +code_llvm_raw(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(STDOUT, f, types, false) """ - code_native([io=stdout,], f, types; syntax = :att) + code_native([io=STDOUT,], f, types; syntax = :att) Prints the native assembly instructions generated for running the method matching the given generic function and type signature to `io`. @@ -132,5 +132,5 @@ Switch assembly syntax using `syntax` symbol parameter set to `:att` for AT&T sy """ code_native(io::IO, @nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = print(io, _dump_function(f, types, true, false, false, false, syntax)) -code_native(@nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = code_native(stdout, f, types, syntax = syntax) +code_native(@nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = code_native(STDOUT, f, types, syntax = syntax) code_native(::IO, ::Any, ::Symbol) = error("illegal code_native call") # resolve ambiguous call diff --git a/stdlib/InteractiveUtils/src/editless.jl b/stdlib/InteractiveUtils/src/editless.jl index 1da9046098d47..6134904e2f751 100644 --- a/stdlib/InteractiveUtils/src/editless.jl +++ b/stdlib/InteractiveUtils/src/editless.jl @@ -73,7 +73,7 @@ function edit(path::AbstractString, line::Integer=0) (Ptr{Cvoid}, Cwstring, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}, Cint), C_NULL, "open", path, C_NULL, C_NULL, 10) ≤ 32) elseif background - run(pipeline(cmd, stderr=stderr), wait=false) + run(pipeline(cmd, stderr=STDERR), wait=false) else run(cmd) end diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index d5f4f139435e4..ec38fb6cf7154 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -136,7 +136,7 @@ end # Issue #16326 mktemp() do f, io - OLDSTDOUT = stdout + OLDSTDOUT = STDOUT redirect_stdout(io) @test try @code_native map(abs, rand(3)); true; catch; false; end redirect_stdout(OLDSTDOUT) diff --git a/stdlib/LibGit2/test/libgit2.jl b/stdlib/LibGit2/test/libgit2.jl index 939ff90644bee..4d314db4dfd88 100644 --- a/stdlib/LibGit2/test/libgit2.jl +++ b/stdlib/LibGit2/test/libgit2.jl @@ -1802,7 +1802,7 @@ mktempdir() do dir @test LibGit2.credential_helpers(cfg, GitCredential("https", "github.com")) == expected - println(stderr, "The following 'Resetting the helper list...' warning is expected:") + println(STDERR, "The following 'Resetting the helper list...' warning is expected:") @test_broken LibGit2.credential_helpers(cfg, GitCredential("https", "mygithost")) == expected[2] end end @@ -2692,7 +2692,7 @@ mktempdir() do dir pem = joinpath(root, common_name * ".pem") # Generated a certificate which has the CN set correctly but no subjectAltName - run(pipeline(`openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout $key -out $cert -days 1 -subj "/CN=$common_name"`, stderr=devnull)) + run(pipeline(`openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout $key -out $cert -days 1 -subj "/CN=$common_name"`, stderr=DevNull)) run(`openssl x509 -in $cert -out $pem -outform PEM`) # Find an available port by listening diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index 79ebfd0e57225..5ca9034b9d8dd 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -334,7 +334,7 @@ const × = cross export ⋅, × -function versioninfo(io::IO=stdout) +function versioninfo(io::IO=STDOUT) if Base.libblas_name == "libopenblas" || BLAS.vendor() == :openblas || BLAS.vendor() == :openblas64 openblas_config = BLAS.openblas_get_config() println(io, "BLAS: libopenblas (", openblas_config, ")") diff --git a/stdlib/Logging/src/ConsoleLogger.jl b/stdlib/Logging/src/ConsoleLogger.jl index 4d518bf13e61c..5030852bffbca 100644 --- a/stdlib/Logging/src/ConsoleLogger.jl +++ b/stdlib/Logging/src/ConsoleLogger.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license """ - ConsoleLogger(stream=stderr, min_level=Info; meta_formatter=default_metafmt, + ConsoleLogger(stream=STDERR, min_level=Info; meta_formatter=default_metafmt, show_limited=true, right_justify=0) Logger with formatting optimized for readability in a text console, for example @@ -30,7 +30,7 @@ struct ConsoleLogger <: AbstractLogger right_justify::Int message_limits::Dict{Any,Int} end -function ConsoleLogger(stream::IO=stderr, min_level=Info; +function ConsoleLogger(stream::IO=STDERR, min_level=Info; meta_formatter=default_metafmt, show_limited=true, right_justify=0) ConsoleLogger(stream, min_level, meta_formatter, diff --git a/stdlib/Logging/src/Logging.jl b/stdlib/Logging/src/Logging.jl index c9fda4fe88d55..50ccac5cd36f7 100644 --- a/stdlib/Logging/src/Logging.jl +++ b/stdlib/Logging/src/Logging.jl @@ -53,7 +53,7 @@ include("ConsoleLogger.jl") # handle_message, shouldlog, min_enabled_level, catch_exceptions, function __init__() - global_logger(ConsoleLogger(stderr)) + global_logger(ConsoleLogger(STDERR)) end end diff --git a/stdlib/Logging/test/runtests.jl b/stdlib/Logging/test/runtests.jl index 9139d19f78297..ee91812d712b6 100644 --- a/stdlib/Logging/test/runtests.jl +++ b/stdlib/Logging/test/runtests.jl @@ -10,11 +10,11 @@ import Logging: min_enabled_level, shouldlog, handle_message @testset "ConsoleLogger" begin # First pass log limiting - @test min_enabled_level(ConsoleLogger(devnull, Logging.Debug)) == Logging.Debug - @test min_enabled_level(ConsoleLogger(devnull, Logging.Error)) == Logging.Error + @test min_enabled_level(ConsoleLogger(DevNull, Logging.Debug)) == Logging.Debug + @test min_enabled_level(ConsoleLogger(DevNull, Logging.Error)) == Logging.Error # Second pass log limiting - logger = ConsoleLogger(devnull) + logger = ConsoleLogger(DevNull) @test shouldlog(logger, Logging.Info, Base, :group, :asdf) === true handle_message(logger, Logging.Info, "msg", Base, :group, :asdf, "somefile", 1, maxlog=2) @test shouldlog(logger, Logging.Info, Base, :group, :asdf) === true diff --git a/stdlib/Pkg/src/Pkg.jl b/stdlib/Pkg/src/Pkg.jl index 11e1c03a8c259..50af37e108797 100644 --- a/stdlib/Pkg/src/Pkg.jl +++ b/stdlib/Pkg/src/Pkg.jl @@ -153,14 +153,14 @@ installed(pkg::AbstractString) = cd(Entry.installed,splitjl(pkg)) Prints out a summary of what packages are installed and what version and state they're in. """ -status(io::IO=stdout) = cd(Entry.status,io) +status(io::IO=STDOUT) = cd(Entry.status,io) """ status(pkg) Prints out a summary of what version and state `pkg`, specifically, is in. """ -status(pkg::AbstractString, io::IO=stdout) = cd(Entry.status,io,splitjl(pkg)) +status(pkg::AbstractString, io::IO=STDOUT) = cd(Entry.status,io,splitjl(pkg)) """ clone(pkg) diff --git a/stdlib/Pkg/src/entry.jl b/stdlib/Pkg/src/entry.jl index e545153f0155b..5534e57caaaad 100644 --- a/stdlib/Pkg/src/entry.jl +++ b/stdlib/Pkg/src/entry.jl @@ -616,7 +616,7 @@ function build(pkg::AbstractString, build_file::AbstractString, errfile::Abstrac --eval $code ``` - success(pipeline(cmd, stdout=stdout, stderr=stderr)) + success(pipeline(cmd, stdout=STDOUT, stderr=STDERR)) end function build!(pkgs::Vector, seen::Set, errfile::AbstractString) @@ -683,7 +683,7 @@ function updatehook(pkgs::Vector) errs = Dict() updatehook!(pkgs,errs) isempty(errs) && return - println(stderr) + println(STDERR) @warn """ ------------------------------------------------------------ # Update hook summary diff --git a/stdlib/Pkg/test/pkg.jl b/stdlib/Pkg/test/pkg.jl index 5e2ea64e63abc..c3364d4529280 100644 --- a/stdlib/Pkg/test/pkg.jl +++ b/stdlib/Pkg/test/pkg.jl @@ -414,13 +414,13 @@ temp_pkg_dir() do touch(depsbuild) # Pkg.build works without the src directory now # but it's probably fine to require it. - msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build("BuildFail")'`, String) + msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build("BuildFail")'`, String) @test occursin("Building BuildFail", msg) @test !occursin("Build failed for BuildFail", msg) open(depsbuild, "w") do fd println(fd, "error(\"Throw build error\")") end - msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build("BuildFail")'`, String) + msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build("BuildFail")'`, String) @test occursin("Building BuildFail", msg) @test occursin("Build failed for BuildFail", msg) @test occursin("Pkg.build(\"BuildFail\")", msg) @@ -431,7 +431,7 @@ temp_pkg_dir() do let package = "Example" Pkg.rm(package) # Remove package if installed @test Pkg.installed(package) === nothing # Registered with METADATA but not installed - msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build(\"$package\")"`), String) + msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build(\"$package\")"`), String) @test occursin("$package is not an installed package", msg) @test !occursin("signal (15)", msg) end @@ -546,7 +546,7 @@ temp_pkg_dir() do Pkg.add(package) msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e - "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); using Example; import Pkg; Pkg.update(\"$package\")"`), String) + "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); using Example; import Pkg; Pkg.update(\"$package\")"`), String) @test occursin(Regex("- $package.*Restart Julia to use the updated versions","s"), msg) end @@ -570,7 +570,7 @@ temp_pkg_dir() do "const JULIA_RC_LOADED = true") withenv((Sys.iswindows() ? "USERPROFILE" : "HOME") => home) do - code = "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build(\"$package\")" + code = "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build(\"$package\")" msg = read(`$(Base.julia_cmd()) --startup-file=no -e $code`, String) @test occursin("JULIA_RC_LOADED defined false", msg) @test occursin("Main.JULIA_RC_LOADED defined false", msg) @@ -579,7 +579,7 @@ temp_pkg_dir() do @test occursin("JULIA_RC_LOADED defined false", msg) @test occursin("Main.JULIA_RC_LOADED defined true", msg) - code = "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.test(\"$package\")" + code = "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.test(\"$package\")" msg = read(`$(Base.julia_cmd()) --startup-file=no -e $code`, String) @test occursin("JULIA_RC_LOADED defined false", msg) @@ -597,8 +597,8 @@ temp_pkg_dir() do stdout_file = Pkg.dir(package, "stdout.txt") stderr_file = Pkg.dir(package, "stderr.txt") content = """ - println(stdout, "stdout") - println(stderr, "stderr") + println(STDOUT, "stdout") + println(STDERR, "stderr") """ write_build(package, content) diff --git a/stdlib/Pkg3/ext/TOML/src/print.jl b/stdlib/Pkg3/ext/TOML/src/print.jl index 7ac2f0afdae69..89d072607d949 100644 --- a/stdlib/Pkg3/ext/TOML/src/print.jl +++ b/stdlib/Pkg3/ext/TOML/src/print.jl @@ -94,4 +94,4 @@ function _print(io::IO, a::AbstractDict, ks=String[]; sorted=false) end print(io::IO, a::AbstractDict; sorted=false) = _print(io, a, sorted=sorted) -print(a::AbstractDict; sorted=false) = print(stdout, a, sorted=sorted) +print(a::AbstractDict; sorted=false) = print(STDOUT, a, sorted=sorted) diff --git a/stdlib/Pkg3/src/Display.jl b/stdlib/Pkg3/src/Display.jl index 80e72fe1ad006..f76295ede17e5 100644 --- a/stdlib/Pkg3/src/Display.jl +++ b/stdlib/Pkg3/src/Display.jl @@ -20,7 +20,7 @@ function git_file_stream(repo::LibGit2.GitRepo, spec::String; fakeit::Bool=false blob = try LibGit2.GitBlob(repo, spec) catch err err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err) - fakeit && return devnull + fakeit && return DevNull end iob = IOBuffer(LibGit2.content(blob)) close(blob) @@ -174,7 +174,7 @@ function print_diff(io::IO, ctx::Context, diff::Vector{DiffEntry}) end end # TODO: Use the Context stream -print_diff(ctx::Context, diff::Vector{DiffEntry}) = print_diff(stdout, ctx, diff) +print_diff(ctx::Context, diff::Vector{DiffEntry}) = print_diff(STDOUT, ctx, diff) function manifest_by_uuid(manifest::Dict) entries = Dict{UUID,Dict}() diff --git a/stdlib/Pkg3/src/GraphType.jl b/stdlib/Pkg3/src/GraphType.jl index 4d069c80d4041..e8d32614a0bdc 100644 --- a/stdlib/Pkg3/src/GraphType.jl +++ b/stdlib/Pkg3/src/GraphType.jl @@ -824,9 +824,9 @@ get_resolve_log(graph::Graph) = deepcopy(graph.data.rlog) const _logindent = " " -showlog(graph::Graph, args...; kw...) = showlog(stdout, graph, args...; kw...) +showlog(graph::Graph, args...; kw...) = showlog(STDOUT, graph, args...; kw...) showlog(io::IO, graph::Graph, args...; kw...) = showlog(io, graph.data.rlog, args...; kw...) -showlog(rlog::ResolveLog, args...; kw...) = showlog(stdout, rlog, args...; kw...) +showlog(rlog::ResolveLog, args...; kw...) = showlog(STDOUT, rlog, args...; kw...) """ Show the full resolution log. The `view` keyword controls how the events are displayed/grouped: diff --git a/stdlib/Pkg3/src/Operations.jl b/stdlib/Pkg3/src/Operations.jl index 3bd23ce9b2c9a..17426f789f1f4 100644 --- a/stdlib/Pkg3/src/Operations.jl +++ b/stdlib/Pkg3/src/Operations.jl @@ -344,7 +344,7 @@ function install_archive( url_success = true cmd = BinaryProvider.gen_download_cmd(archive_url, path); try - run(cmd, (devnull, devnull, devnull)) + run(cmd, (DevNull, DevNull, DevNull)) catch e e isa InterruptException && rethrow(e) url_success = false @@ -355,7 +355,7 @@ function install_archive( cmd = BinaryProvider.gen_unpack_cmd(path, dir); # Might fail to extract an archive (Pkg3#190) try - run(cmd, (devnull, devnull, devnull)) + run(cmd, (DevNull, DevNull, DevNull)) catch e e isa InterruptException && rethrow(e) @warn "failed to extract archive downloaded from $(archive_url)" diff --git a/stdlib/Pkg3/src/REPLMode.jl b/stdlib/Pkg3/src/REPLMode.jl index 02976b24a3c3d..76e16a88a074c 100644 --- a/stdlib/Pkg3/src/REPLMode.jl +++ b/stdlib/Pkg3/src/REPLMode.jl @@ -725,7 +725,7 @@ struct MiniREPL <: REPL.AbstractREPL t::REPL.Terminals.TTYTerminal end function MiniREPL() - MiniREPL(TextDisplay(stdout), REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), stdin, stdout, stderr)) + MiniREPL(TextDisplay(STDOUT), REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR)) end REPL.REPLDisplay(repl::MiniREPL) = repl.display diff --git a/stdlib/Pkg3/src/Types.jl b/stdlib/Pkg3/src/Types.jl index 56c1c724e9449..7b4eb47c24fb8 100644 --- a/stdlib/Pkg3/src/Types.jl +++ b/stdlib/Pkg3/src/Types.jl @@ -581,7 +581,7 @@ function read_project(io::IO) return project end function read_project(file::String) - isfile(file) ? open(read_project, file) : read_project(devnull) + isfile(file) ? open(read_project, file) : read_project(DevNull) end function read_manifest(io::IO) @@ -602,7 +602,7 @@ function read_manifest(io::IO) return manifest end function read_manifest(file::String) - try isfile(file) ? open(read_manifest, file) : read_manifest(devnull) + try isfile(file) ? open(read_manifest, file) : read_manifest(DevNull) catch err err isa ErrorException && startswith(err.msg, "ambiguious dependency") || rethrow(err) err.msg *= "In manifest file: $file" @@ -963,9 +963,9 @@ function registries(; clone_default=true)::Vector{String} if clone_default if !ispath(user_regs) mkpath(user_regs) - printpkgstyle(stdout, :Cloning, "default registries into $user_regs") + printpkgstyle(STDOUT, :Cloning, "default registries into $user_regs") for (reg, url) in DEFAULT_REGISTRIES - printpkgstyle(stdout, :Cloning, "registry $reg from $(repr(url))") + printpkgstyle(STDOUT, :Cloning, "registry $reg from $(repr(url))") path = joinpath(user_regs, reg) repo = LibGit2.clone(url, path) close(repo) @@ -1177,7 +1177,7 @@ end # TODO: use ctx specific context function printpkgstyle(ctx::Context, cmd::Symbol, text::String...; kwargs...) - printpkgstyle(stdout, cmd, text...; kwargs...) + printpkgstyle(STDOUT, cmd, text...; kwargs...) end diff --git a/stdlib/Pkg3/src/generate.jl b/stdlib/Pkg3/src/generate.jl index 35827604cdadf..ba2381fad708a 100644 --- a/stdlib/Pkg3/src/generate.jl +++ b/stdlib/Pkg3/src/generate.jl @@ -10,7 +10,7 @@ end function genfile(f::Function, pkg::String, dir::String, file::String) path = joinpath(dir, pkg, file) - println(stdout, " $path") + println(STDOUT, " $path") mkpath(dirname(path)) open(f, path, "w") return diff --git a/stdlib/Pkg3/src/precompile.jl b/stdlib/Pkg3/src/precompile.jl index e20ee5d367ea2..dfd8e0c80441f 100644 --- a/stdlib/Pkg3/src/precompile.jl +++ b/stdlib/Pkg3/src/precompile.jl @@ -121,7 +121,7 @@ precompile(Tuple{getfield(Base, Symbol("#@show")), LineNumberNode, Module, Expr} precompile(Tuple{getfield(Base, Symbol("#@time")), LineNumberNode, Module, Expr}) precompile(Tuple{getfield(Base, Symbol("#kw##_spawn")), NamedTuple{(:chain,), Tuple{Nothing}}, typeof(Base._spawn), Base.Cmd, Tuple{Base.DevNullStream, Base.IOStream, Base.IOStream}}) precompile(Tuple{getfield(Base, Symbol("#kw##_spawn")), NamedTuple{(:chain,), Tuple{Nothing}}, typeof(Base._spawn), Base.CmdRedirect, Tuple{Base.DevNullStream, Base.DevNullStream, Base.IOStream}}) -precompile(Tuple{getfield(Base, Symbol("#kw##pipeline")), NamedTuple{(:stdout, :stderr), Tuple{Base.IOStream, Base.IOStream}}, typeof(Base.pipeline), Base.Cmd}) +precompile(Tuple{getfield(Base, Symbol("#kw##pipeline")), NamedTuple{(:STDOUT, :STDERR), Tuple{Base.IOStream, Base.IOStream}}, typeof(Base.pipeline), Base.Cmd}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.TTY, String}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), String, String}) precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), String}) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 44d192e1c4739..6abf46719b8b4 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -36,7 +36,7 @@ julia> @printf "%.0f %.1f %f\\n" 0.5 0.025 -0.0078125 macro printf(args...) isempty(args) && throw(ArgumentError("@printf: called with no arguments")) if isa(args[1], AbstractString) || is_str_expr(args[1]) - _printf("@printf", :stdout, args[1], args[2:end]) + _printf("@printf", :STDOUT, args[1], args[2:end]) else (length(args) >= 2 && (isa(args[2], AbstractString) || is_str_expr(args[2]))) || throw(ArgumentError("@printf: first or second argument must be a format string")) diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 0fe5d69f5bcd6..46acffc753391 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -101,9 +101,9 @@ struct ProfileFormat end """ - print([io::IO = stdout,] [data::Vector]; kwargs...) + print([io::IO = STDOUT,] [data::Vector]; kwargs...) -Prints profiling results to `io` (by default, `stdout`). If you do not +Prints profiling results to `io` (by default, `STDOUT`). If you do not supply a `data` vector, the internal buffer of accumulated backtraces will be used. @@ -156,7 +156,7 @@ function print(io::IO, data::Vector{<:Unsigned}, lidict::LineInfoDict, fmt::Prof end """ - print([io::IO = stdout,] data::Vector, lidict::LineInfoDict; kwargs...) + print([io::IO = STDOUT,] data::Vector, lidict::LineInfoDict; kwargs...) Prints profiling results to `io`. This variant is used to examine results exported by a previous call to [`retrieve`](@ref). Supply the vector `data` of backtraces and @@ -165,7 +165,7 @@ a dictionary `lidict` of line information. See `Profile.print([io], data)` for an explanation of the valid keyword arguments. """ print(data::Vector{<:Unsigned} = fetch(), lidict::LineInfoDict = getdict(data); kwargs...) = - print(stdout, data, lidict; kwargs...) + print(STDOUT, data, lidict; kwargs...) """ retrieve() -> data, lidict diff --git a/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl b/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl index 35783ed63e12c..d25a8acb5d2d8 100644 --- a/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl +++ b/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl @@ -6,7 +6,7 @@ import REPL function __init__() global terminal - terminal = REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), stdin, stdout, stderr) + terminal = REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR) end include("util.jl") diff --git a/stdlib/REPL/src/TerminalMenus/util.jl b/stdlib/REPL/src/TerminalMenus/util.jl index fa8c803a365cd..8dac811e0e5ab 100644 --- a/stdlib/REPL/src/TerminalMenus/util.jl +++ b/stdlib/REPL/src/TerminalMenus/util.jl @@ -33,14 +33,14 @@ function disableRawMode(term) end -# Reads a single byte from stdin -readNextChar(stream::IO=stdin) = Char(read(stream,1)[1]) +# Reads a single byte from STDIN +readNextChar(stream::IO=STDIN) = Char(read(stream,1)[1]) -# Read the next key from stdin. It is also able to read several bytes for +# Read the next key from STDIN. It is also able to read several bytes for # escaped keys such as the arrow keys, home/end keys, etc. # Escaped keys are returned using the `Key` enum. -readKey(stream::IO=stdin) = UInt32(_readKey(stream)) -function _readKey(stream::IO=stdin) +readKey(stream::IO=STDIN) = UInt32(_readKey(stream)) +function _readKey(stream::IO=STDIN) c = readNextChar(stream) # Escape characters diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 006a43ae471d9..a31b6d543594b 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -17,7 +17,7 @@ using InteractiveUtils: subtypes # This is split into helpmode and _helpmode to easier unittest _helpmode helpmode(io::IO, line::AbstractString) = :($REPL.insert_hlines($io, $(REPL._helpmode(io, line)))) -helpmode(line::AbstractString) = helpmode(stdout, line) +helpmode(line::AbstractString) = helpmode(STDOUT, line) function _helpmode(io::IO, line::AbstractString) line = strip(line) @@ -39,7 +39,7 @@ function _helpmode(io::IO, line::AbstractString) # so that the resulting expressions are evaluated in the Base.Docs namespace :($REPL.@repl $io $expr) end -_helpmode(line::AbstractString) = _helpmode(stdout, line) +_helpmode(line::AbstractString) = _helpmode(STDOUT, line) # Print vertical lines along each docstring if there are multiple docs function insert_hlines(io::IO, docs) @@ -224,14 +224,14 @@ function repl_search(io::IO, s) printmatches(io, s, doc_completions(s), cols = displaysize(io)[2] - length(pre)) println(io, "\n") end -repl_search(s) = repl_search(stdout, s) +repl_search(s) = repl_search(STDOUT, s) function repl_corrections(io::IO, s) print(io, "Couldn't find ") printstyled(io, s, '\n', color=:cyan) print_correction(io, s) end -repl_corrections(s) = repl_corrections(stdout, s) +repl_corrections(s) = repl_corrections(STDOUT, s) # inverse of latex_symbols Dict, lazily created as needed const symbols_latex = Dict{String,String}() @@ -268,7 +268,7 @@ function repl_latex(io::IO, s::String) println(io, '\n') end end -repl_latex(s::String) = repl_latex(stdout, s) +repl_latex(s::String) = repl_latex(STDOUT, s) macro repl(ex) repl(ex) end macro repl(io, ex) repl(io, ex) end @@ -290,7 +290,7 @@ repl(io::IO, str::AbstractString) = :(apropos($io, $str)) repl(io::IO, other) = esc(:(@doc $other)) #repl(io::IO, other) = lookup_doc(other) # TODO -repl(x) = repl(stdout, x) +repl(x) = repl(STDOUT, x) function _repl(x) if (isexpr(x, :call) && !any(isexpr(x, :(::)) for x in x.args)) @@ -430,7 +430,7 @@ function printmatch(io::IO, word, match) end end -printmatch(args...) = printfuzzy(stdout, args...) +printmatch(args...) = printfuzzy(STDOUT, args...) function printmatches(io::IO, word, matches; cols = displaysize(io)[2]) total = 0 @@ -443,7 +443,7 @@ function printmatches(io::IO, word, matches; cols = displaysize(io)[2]) end end -printmatches(args...; cols = displaysize(stdout)[2]) = printmatches(stdout, args..., cols = cols) +printmatches(args...; cols = displaysize(STDOUT)[2]) = printmatches(STDOUT, args..., cols = cols) function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displaysize(io)[2]) i = 0 @@ -455,7 +455,7 @@ function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displays join(io, ss[1:i], delim, last) end -print_joined_cols(args...; cols = displaysize(stdout)[2]) = print_joined_cols(stdout, args...; cols=cols) +print_joined_cols(args...; cols = displaysize(STDOUT)[2]) = print_joined_cols(STDOUT, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(Main)) @@ -466,7 +466,7 @@ function print_correction(io, word) return end -print_correction(word) = print_correction(stdout, word) +print_correction(word) = print_correction(STDOUT, word) # Completion data @@ -566,7 +566,7 @@ stripmd(x::Markdown.Table) = Search through all documentation for a string, ignoring case. """ -apropos(string) = apropos(stdout, string) +apropos(string) = apropos(STDOUT, string) apropos(io::IO, string) = apropos(io, Regex("\\Q$string", "i")) function apropos(io::IO, needle::Regex) for mod in modules diff --git a/stdlib/REPL/test/TerminalMenus/radio_menu.jl b/stdlib/REPL/test/TerminalMenus/radio_menu.jl index a8281271cd53d..05d73605d2799 100644 --- a/stdlib/REPL/test/TerminalMenus/radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/radio_menu.jl @@ -33,6 +33,6 @@ TerminalMenus.config(charset=:unicode) TerminalMenus.writeLine(buf, radio_menu, 1, true) @test String(take!(buf)) == string(CONFIG[:cursor], " 1") -# Test using stdin +# Test using STDIN radio_menu = RadioMenu(string.(1:10)) @test simulateInput(3, radio_menu, :down, :down, :enter) diff --git a/stdlib/REPL/test/TerminalMenus/runtests.jl b/stdlib/REPL/test/TerminalMenus/runtests.jl index 7034d16b1d3ca..d0047d77573f8 100644 --- a/stdlib/REPL/test/TerminalMenus/runtests.jl +++ b/stdlib/REPL/test/TerminalMenus/runtests.jl @@ -6,7 +6,7 @@ TerminalMenus.config(supress_output=true) function simulateInput(expectedResult, menu::TerminalMenus.AbstractMenu, keys...) # If we cannot write to the buffer, skip the test - !(:buffer in fieldnames(typeof(stdin))) && return true + !(:buffer in fieldnames(typeof(STDIN))) && return true keydict = Dict(:up => "\e[A", :down => "\e[B", @@ -14,9 +14,9 @@ function simulateInput(expectedResult, menu::TerminalMenus.AbstractMenu, keys... for key in keys if isa(key, Symbol) - write(stdin.buffer, keydict[key]) + write(STDIN.buffer, keydict[key]) else - write(stdin.buffer, "$key") + write(STDIN.buffer, "$key") end end diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 61451af53e2d8..06cee5762ffe4 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -21,24 +21,24 @@ function fake_repl(f; options::REPL.Options=REPL.Options(confirm_exit=false)) # Use pipes so we can easily do blocking reads # In the future if we want we can add a test that the right object # gets displayed by intercepting the display - input = Pipe() - output = Pipe() - err = Pipe() - Base.link_pipe!(input, reader_supports_async=true, writer_supports_async=true) - Base.link_pipe!(output, reader_supports_async=true, writer_supports_async=true) - Base.link_pipe!(err, reader_supports_async=true, writer_supports_async=true) - - repl = REPL.LineEditREPL(FakeTerminal(input.out, output.in, err.in), true) + stdin = Pipe() + stdout = Pipe() + stderr = Pipe() + Base.link_pipe!(stdin, reader_supports_async=true, writer_supports_async=true) + Base.link_pipe!(stdout, reader_supports_async=true, writer_supports_async=true) + Base.link_pipe!(stderr, reader_supports_async=true, writer_supports_async=true) + + repl = REPL.LineEditREPL(FakeTerminal(stdin.out, stdout.in, stderr.in), true) repl.options = options - f(input.in, output.out, repl) + f(stdin.in, stdout.out, repl) t = @async begin - close(input.in) - close(output.in) - close(err.in) + close(stdin.in) + close(stdout.in) + close(stderr.in) end - @test read(err.out, String) == "" - #display(read(output.out, String)) + @test read(stderr.out, String) == "" + #display(read(stdout.out, String)) Base._wait(t) nothing end @@ -158,7 +158,7 @@ fake_repl() do stdin_write, stdout_read, repl # issue #10120 # ensure that command quoting works correctly - let s, old_stdout = stdout + let s, old_stdout = STDOUT write(stdin_write, ";") readuntil(stdout_read, "shell> ") Base.print_shell_escaped(stdin_write, Base.julia_cmd().exec..., special=Base.shell_special) @@ -904,7 +904,7 @@ for (line, expr) in Pair[ "\"...\"" => "...", "r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "...") ] - #@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), stdout, expr) + #@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), STDOUT, expr) buf = IOBuffer() @test eval(Base, REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing} end diff --git a/stdlib/Random/src/RNGs.jl b/stdlib/Random/src/RNGs.jl index f4e4fda97210d..01d97f4c84019 100644 --- a/stdlib/Random/src/RNGs.jl +++ b/stdlib/Random/src/RNGs.jl @@ -239,7 +239,7 @@ function make_seed() try return rand(RandomDevice(), UInt32, 4) catch - println(stderr, + println(STDERR, "Entropy pool not available to seed RNG; using ad-hoc entropy sources.") seed = reinterpret(UInt64, time()) seed = hash(seed, UInt64(getpid())) diff --git a/stdlib/Test/src/Test.jl b/stdlib/Test/src/Test.jl index 64f8b3a6890d5..ac97941049f42 100644 --- a/stdlib/Test/src/Test.jl +++ b/stdlib/Test/src/Test.jl @@ -541,7 +541,7 @@ contains_warn(output, S::Union{AbstractArray,Tuple}) = all(s -> contains_warn(ou """ @test_warn msg expr -Test whether evaluating `expr` results in [`stderr`](@ref) output that contains +Test whether evaluating `expr` results in [`STDERR`](@ref) output that contains the `msg` string or matches the `msg` regular expression. If `msg` is a boolean function, tests whether `msg(output)` returns `true`. If `msg` is a tuple or array, checks that the error output contains/matches each item in `msg`. @@ -570,7 +570,7 @@ end """ @test_nowarn expr -Test whether evaluating `expr` results in empty [`stderr`](@ref) output +Test whether evaluating `expr` results in empty [`STDERR`](@ref) output (no warnings or other messages). Returns the result of evaluating `expr`. """ macro test_nowarn(expr) @@ -694,7 +694,7 @@ function record(ts::DefaultTestSet, t::Union{Fail, Error}) # don't print the backtrace for Errors because it gets printed in the show # method if !isa(t, Error) - Base.show_backtrace(stdout, scrub_backtrace(backtrace())) + Base.show_backtrace(STDOUT, scrub_backtrace(backtrace())) end println() end @@ -712,7 +712,7 @@ function print_test_errors(ts::DefaultTestSet) for t in ts.results if (isa(t, Error) || isa(t, Fail)) && myid() == 1 println("Error in testset $(ts.description):") - Base.show(stdout,t) + Base.show(STDOUT,t) println() elseif isa(t, DefaultTestSet) print_test_errors(t) diff --git a/stdlib/Test/src/logging.jl b/stdlib/Test/src/logging.jl index 47c76b5820568..d837fc336989c 100644 --- a/stdlib/Test/src/logging.jl +++ b/stdlib/Test/src/logging.jl @@ -86,7 +86,7 @@ function record(ts::DefaultTestSet, t::LogTestFailure) if myid() == 1 printstyled(ts.description, ": ", color=:white) print(t) - Base.show_backtrace(stdout, scrub_backtrace(backtrace())) + Base.show_backtrace(STDOUT, scrub_backtrace(backtrace())) println() end # Hack: convert to `Fail` so that test summarization works correctly diff --git a/stdlib/Test/test/runtests.jl b/stdlib/Test/test/runtests.jl index 41688cc9aa732..9615f65012c78 100644 --- a/stdlib/Test/test/runtests.jl +++ b/stdlib/Test/test/runtests.jl @@ -53,7 +53,7 @@ end end @testset "@test_warn" begin @test 1234 === @test_nowarn(1234) - @test 5678 === @test_warn("WARNING: foo", begin println(stderr, "WARNING: foo"); 5678; end) + @test 5678 === @test_warn("WARNING: foo", begin println(STDERR, "WARNING: foo"); 5678; end) let a @test_throws UndefVarError(:a) a @test_nowarn a = 1 @@ -204,8 +204,8 @@ end @test Test.finish(Test.FallbackTestSet()) !== nothing -OLD_STDOUT = stdout -OLD_STDERR = stderr +OLD_STDOUT = STDOUT +OLD_STDERR = STDERR catch_out = IOStream("") catch_err = IOStream("") rde, wre = redirect_stderr() @@ -393,7 +393,7 @@ catch end @test ts isa Test.DefaultTestSet -# now we're done running tests with DefaultTestSet so we can go back to stdout +# now we're done running tests with DefaultTestSet so we can go back to STDOUT redirect_stdout(OLD_STDOUT) redirect_stderr(OLD_STDERR) @@ -547,7 +547,7 @@ end @test_throws MethodError 1 end """) - local msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=devnull), String) + local msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=DevNull), String) # NOTE: This test depends on the code generated by @testset getting compiled, # to get good backtraces. If it fails, check the implementation of `testset_beginend`. @test !occursin("do_test(", msg) @@ -594,7 +594,7 @@ let msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --co @test foo(zeros(2)) == 4 @test foo(fill(1., 4)) == 15 end - end'`), stderr=devnull), String) + end'`), stderr=DevNull), String) @test occursin(""" Test Summary: | Pass Fail Total Foo Tests | 2 2 4 @@ -607,7 +607,7 @@ end # 20489 let msg = split(read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no -e ' - Test.print_test_results(Test.DefaultTestSet(""))'`), stderr=devnull), String), "\n")[1] + Test.print_test_results(Test.DefaultTestSet(""))'`), stderr=DevNull), String), "\n")[1] @test msg == rstrip(msg) end @@ -644,7 +644,7 @@ end end """) - local msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=devnull), String) + local msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=DevNull), String) @test occursin("at " * f * ":" * "3", msg) @test occursin("at " * f * ":" * "4", msg) @test occursin("at " * f * ":" * "5", msg) @@ -655,7 +655,7 @@ end # issue #24919 @testset "≈ with atol" begin local cmd = `$(Base.julia_cmd()) --startup-file=no --color=no` - f(src) = read(pipeline(ignorestatus(`$cmd -e $src`), stderr=devnull), String) + f(src) = read(pipeline(ignorestatus(`$cmd -e $src`), stderr=DevNull), String) msg = f(""" using Test @@ -794,7 +794,7 @@ end @test e isa InterruptException end """) - msg = success(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=devnull)) + msg = success(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no $f`), stderr=DevNull)) end @testset "non AbstractTestSet as testset" begin @@ -841,4 +841,4 @@ end @testset "splatting in isapprox" begin a = [1, 2, 3] @test isapprox(identity.((a, a))...) -end \ No newline at end of file +end diff --git a/test/boundscheck.jl b/test/boundscheck.jl index 09cc8d2cd13e8..a1ca1b8051536 100644 --- a/test/boundscheck.jl +++ b/test/boundscheck.jl @@ -3,16 +3,16 @@ # run boundscheck tests on separate workers launched with --check-bounds={default,yes,no} cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) +if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("boundscheck test failed, cmd : $cmd") end cmd = `$(Base.julia_cmd()) --check-bounds=yes --startup-file=no --depwarn=error boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) +if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("boundscheck test failed, cmd : $cmd") end cmd = `$(Base.julia_cmd()) --check-bounds=no --startup-file=no --depwarn=error boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) +if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("boundscheck test failed, cmd : $cmd") end diff --git a/test/ccall.jl b/test/ccall.jl index 5f129ed3b3cae..3f124e2dd952a 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1248,8 +1248,8 @@ end @noinline f21104at(::Type{T}) where {T} = ccall(:fn, Cvoid, (Some{T},), Some(0)) @noinline f21104rt(::Type{T}) where {T} = ccall(:fn, Some{T}, ()) -@test code_llvm(devnull, f21104at, (Type{Float64},)) === nothing -@test code_llvm(devnull, f21104rt, (Type{Float64},)) === nothing +@test code_llvm(DevNull, f21104at, (Type{Float64},)) === nothing +@test code_llvm(DevNull, f21104rt, (Type{Float64},)) === nothing @test_throws(ErrorException("ccall argument 1 doesn't correspond to a C type"), f21104at(Float64)) @test_throws(ErrorException("ccall return type doesn't correspond to a C type"), diff --git a/test/channels.jl b/test/channels.jl index 07033c6cc7c64..d01292bf71675 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -238,7 +238,7 @@ end GC.enable(true) GC.gc() end - oldstderr = stderr + oldstderr = STDERR local newstderr, errstream try newstderr = redirect_stderr() diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 675b1a88b56c7..26e16cc925e02 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -18,7 +18,7 @@ end function readchomperrors(exename::Cmd) out = Base.PipeEndpoint() err = Base.PipeEndpoint() - p = run(exename, devnull, out, err, wait=false) + p = run(exename, DevNull, out, err, wait=false) o = @async(readchomp(out)) e = @async(readchomp(err)) return (success(p), fetch(o), fetch(e)) @@ -219,7 +219,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` # -g @test readchomp(`$exename -E "Base.JLOptions().debug_level" -g`) == "2" - let code = writereadpipeline("code_llvm(stdout, +, (Int64, Int64), false, true)", `$exename -g0`) + let code = writereadpipeline("code_llvm(STDOUT, +, (Int64, Int64), false, true)", `$exename -g0`) @test code[2] code = code[1] @test occursin("llvm.module.flags", code) @@ -227,7 +227,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` @test !occursin("int.jl", code) @test !occursin("Int64", code) end - let code = writereadpipeline("code_llvm(stdout, +, (Int64, Int64), false, true)", `$exename -g1`) + let code = writereadpipeline("code_llvm(STDOUT, +, (Int64, Int64), false, true)", `$exename -g1`) @test code[2] code = code[1] @test occursin("llvm.module.flags", code) @@ -235,7 +235,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` @test occursin("int.jl", code) @test !occursin("Int64", code) end - let code = writereadpipeline("code_llvm(stdout, +, (Int64, Int64), false, true)", `$exename -g2`) + let code = writereadpipeline("code_llvm(STDOUT, +, (Int64, Int64), false, true)", `$exename -g2`) @test code[2] code = code[1] @test occursin("llvm.module.flags", code) @@ -327,7 +327,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` # test passing arguments mktempdir() do dir testfile = joinpath(dir, tempname()) - # write a julia source file that just prints ARGS to stdout + # write a julia source file that just prints ARGS to STDOUT write(testfile, """ println(ARGS) """) @@ -483,7 +483,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes` end # Make sure `julia --lisp` doesn't break -run(pipeline(devnull, `$(joinpath(Sys.BINDIR, Base.julia_exename())) --lisp`, devnull)) +run(pipeline(DevNull, `$(joinpath(Sys.BINDIR, Base.julia_exename())) --lisp`, DevNull)) # Test that `julia [some other option] --lisp` is disallowed @test readchomperrors(`$(joinpath(Sys.BINDIR, Base.julia_exename())) -Cnative --lisp`) == diff --git a/test/compiler/compiler.jl b/test/compiler/compiler.jl index 76c206037d976..3e7964aba8861 100644 --- a/test/compiler/compiler.jl +++ b/test/compiler/compiler.jl @@ -169,12 +169,12 @@ mutable struct A14009{T}; end A14009(a::T) where {T} = A14009{T}() f14009(a) = rand(Bool) ? f14009(A14009(a)) : a code_typed(f14009, (Int,)) -code_llvm(devnull, f14009, (Int,)) +code_llvm(DevNull, f14009, (Int,)) mutable struct B14009{T}; end g14009(a) = g14009(B14009{a}) code_typed(g14009, (Type{Int},)) -code_llvm(devnull, f14009, (Int,)) +code_llvm(DevNull, f14009, (Int,)) # issue #9232 @@ -188,7 +188,7 @@ result_type9232(::Type{T1}, ::Type{T2}) where {T1<:Number,T2<:Number} = arithtyp function g10878(x; kw...); end invoke_g10878() = invoke(g10878, Tuple{Any}, 1) code_typed(invoke_g10878, ()) -code_llvm(devnull, invoke_g10878, ()) +code_llvm(DevNull, invoke_g10878, ()) # issue #10930 diff --git a/test/core.jl b/test/core.jl index 661fd3914f2fc..ffb55b72d7c8d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2573,7 +2573,7 @@ end === nothing # issue #10221 module GCbrokentype using InteractiveUtils -OLD_STDOUT = stdout +OLD_STDOUT = STDOUT fname = tempname() file = open(fname, "w") redirect_stdout(file) @@ -4388,7 +4388,7 @@ end @test f16158("abc") == "abcaba" # LLVM verifier error for noreturn function -# the `code_llvm(devnull, ...)` tests are only meaningful on debug build +# the `code_llvm(DevNull, ...)` tests are only meaningful on debug build # with verifier on (but should still pass on release build). module TestSSA16244 @@ -4404,7 +4404,7 @@ function f1(a) end b[1] end -code_llvm(devnull, f1, Tuple{Bool}) +code_llvm(DevNull, f1, Tuple{Bool}) @test f1(true) == 2 @test_throws DivideError f1(false) @@ -4419,7 +4419,7 @@ function f2(a) end b[1] end -code_llvm(devnull, f2, Tuple{Bool}) +code_llvm(DevNull, f2, Tuple{Bool}) @test f2(true) == 2 @test_throws ErrorException f2(false) @@ -4430,7 +4430,7 @@ function f3(a) end b[1] end -code_llvm(devnull, f3, Tuple{Bool}) +code_llvm(DevNull, f3, Tuple{Bool}) @test f3(true) == 2 ex = try f3(false) @@ -4449,7 +4449,7 @@ function f4(a, p) end b[1] end -code_llvm(devnull, f4, Tuple{Bool,Ptr{Cvoid}}) +code_llvm(DevNull, f4, Tuple{Bool,Ptr{Cvoid}}) @test f4(true, C_NULL) == 2 @test_throws UndefRefError f4(false, C_NULL) @@ -4461,7 +4461,7 @@ function f5(a) end b[1] end -code_llvm(devnull, f5, Tuple{Bool}) +code_llvm(DevNull, f5, Tuple{Bool}) @test f5(true) == 2 @test f5(false) == 1 @@ -4472,7 +4472,7 @@ function f6(a) end b[1] end -code_llvm(devnull, f6, Tuple{Bool}) +code_llvm(DevNull, f6, Tuple{Bool}) @test f6(true) == 2 @test f6(false) == 1 @@ -4485,7 +4485,7 @@ function f7(a) end b[1] end -code_llvm(devnull, f7, Tuple{Bool}) +code_llvm(DevNull, f7, Tuple{Bool}) @test f7(true) == 2 @test_throws TypeError f7(false) @@ -4498,7 +4498,7 @@ function f8(a, c) end b[1] end -code_llvm(devnull, f8, Tuple{Bool,Int}) +code_llvm(DevNull, f8, Tuple{Bool,Int}) @test f8(true, 1) == 2 @test_throws TypeError f8(false, 1) @@ -4512,7 +4512,7 @@ function f9(a) end b[1] end -code_llvm(devnull, f9, Tuple{Bool}) +code_llvm(DevNull, f9, Tuple{Bool}) @test f9(true) == 2 ex = try f9(false) diff --git a/test/deprecation_exec.jl b/test/deprecation_exec.jl index 143e32a1ee758..b98b82f8ba8ca 100644 --- a/test/deprecation_exec.jl +++ b/test/deprecation_exec.jl @@ -278,17 +278,17 @@ end @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest, :bar; kind=:info) +logging(DevNull, LogTest, :bar; kind=:info) @test all(occursin.(["WARNING: barwarn", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest; kind=:info) +logging(DevNull, LogTest; kind=:info) @test all(occursin.(["WARNING: barwarn", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull; kind=:info) +logging(DevNull; kind=:info) @test all(occursin.(["WARNING: barwarn", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) @@ -299,17 +299,17 @@ logging(kind=:info) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest, :bar; kind=:warn) +logging(DevNull, LogTest, :bar; kind=:warn) @test all(occursin.(["INFO: barinfo", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest; kind=:warn) +logging(DevNull, LogTest; kind=:warn) @test all(occursin.(["INFO: barinfo", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull; kind=:warn) +logging(DevNull; kind=:warn) @test all(occursin.(["INFO: barinfo", "ERROR: \"barerror\""], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "ERROR: \"fooerror\""], sprint(foo))) @@ -320,17 +320,17 @@ logging(kind=:warn) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest, :bar; kind=:error) +logging(DevNull, LogTest, :bar; kind=:error) @test all(occursin.(["INFO: barinfo", "WARNING: barwarn"], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest; kind=:error) +logging(DevNull, LogTest; kind=:error) @test all(occursin.(["INFO: barinfo", "WARNING: barwarn"], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn"], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull; kind=:error) +logging(DevNull; kind=:error) @test all(occursin.(["INFO: barinfo", "WARNING: barwarn"], sprint(LogTest.bar))) @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn"], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn"], sprint(foo))) @@ -341,17 +341,17 @@ logging(kind=:error) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest, :bar) +logging(DevNull, LogTest, :bar) @test sprint(LogTest.bar) == "" @test all(occursin.(["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""], sprint(LogTest.pooh))) @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull, LogTest) +logging(DevNull, LogTest) @test sprint(LogTest.bar) == "" @test sprint(LogTest.pooh) == "" @test all(occursin.(["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""], sprint(foo))) -logging(devnull) +logging(DevNull) @test sprint(LogTest.bar) == "" @test sprint(LogTest.pooh) == "" @test sprint(foo) == "" diff --git a/test/embedding/embedding-test.jl b/test/embedding/embedding-test.jl index 2be2842ac8967..0ea3946c01b02 100644 --- a/test/embedding/embedding-test.jl +++ b/test/embedding/embedding-test.jl @@ -12,14 +12,14 @@ end @testset "embedding example" begin out = Pipe() err = Pipe() - p = run(pipeline(Cmd(ARGS), stdin=devnull, stdout=out, stderr=err), wait=false) + p = run(pipeline(Cmd(ARGS), stdin=DevNull, stdout=out, stderr=err), wait=false) close(out.in) close(err.in) out_task = @async readlines(out) err = read(err, String) @test err == "MethodError: no method matching this_function_has_no_methods()\n" @test success(p) - lines = fetch(out_task) + lines = fetch(stdout_task) @test length(lines) == 10 @test parse(Float64, lines[1]) ≈ sqrt(2) @test lines[8] == "called bar" diff --git a/test/examples.jl b/test/examples.jl index 04d1b54d0025e..74c75030d300e 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -42,7 +42,7 @@ include(joinpath(dir, "queens.jl")) if Sys.isunix() script = joinpath(dir, "clustermanager/simple/test_simple.jl") cmd = `$(Base.julia_cmd()) --startup-file=no $script` - if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 + if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 error("UnixDomainCM failed test, cmd : $cmd") end end diff --git a/test/file.jl b/test/file.jl index 33c4ccd172cfd..06b1069fdf23f 100644 --- a/test/file.jl +++ b/test/file.jl @@ -1004,13 +1004,13 @@ function test_13559() write(x, 0xaa) end flush(x) - Test.@test read(stdin, Int8) == 31 + Test.@test read(STDIN, Int8) == 31 for i in 1:7 write(x, 0xaa) end close(x) """ - p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=stderr), "w") + p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=STDERR), "w") # quickly read FIFO, draining it and blocking but not failing with EOFError yet r = open(fn, "r") # 15 proper reads @@ -1040,11 +1040,11 @@ if !Sys.iswindows() && !(Sys.isbsd() && !Sys.isapple()) x = open($(repr(fn)), "w") write(x, 0x42) flush(x) - Test.@test read(stdin, Int8) == 21 + Test.@test read(STDIN, Int8) == 21 close(x) """ cmd = `$(Base.julia_cmd()) --startup-file=no -e $script` - p = open(pipeline(cmd, stderr=stderr), "w") + p = open(pipeline(cmd, stderr=STDERR), "w") r = open(fn, "r") @test read(r, Int8) == 66 diff --git a/test/llvmcall.jl b/test/llvmcall.jl index c92d2be67add9..f05ac12b57bce 100644 --- a/test/llvmcall.jl +++ b/test/llvmcall.jl @@ -189,7 +189,7 @@ if Base.libllvm_version >= v"3.6" # llvm 3.6 changed the syntax for a gep, so ju ret void""", Cvoid, Tuple{}) end - code_llvm(devnull, foo, ()) + code_llvm(DevNull, foo, ()) else @info "Skipping gep parentage test on llvm < 3.6" end diff --git a/test/logging.jl b/test/logging.jl index 28874079c744c..061f93f7d358e 100644 --- a/test/logging.jl +++ b/test/logging.jl @@ -221,11 +221,11 @@ end @testset "SimpleLogger" begin # Log level limiting - @test min_enabled_level(SimpleLogger(devnull, Debug)) == Debug - @test min_enabled_level(SimpleLogger(devnull, Error)) == Error + @test min_enabled_level(SimpleLogger(DevNull, Debug)) == Debug + @test min_enabled_level(SimpleLogger(DevNull, Error)) == Error # Log limiting - logger = SimpleLogger(devnull) + logger = SimpleLogger(DevNull) @test shouldlog(logger, Info, Base, :group, :asdf) === true handle_message(logger, Info, "msg", Base, :group, :asdf, "somefile", 1, maxlog=2) @test shouldlog(logger, Info, Base, :group, :asdf) === true diff --git a/test/meta.jl b/test/meta.jl index 8c688d2cf8c77..ffca57401490f 100644 --- a/test/meta.jl +++ b/test/meta.jl @@ -159,7 +159,7 @@ end @test _nospec_with_default(10) == 20 -let oldout = stdout +let oldout = STDOUT local rdout, wrout, out try rdout, wrout = redirect_stdout() diff --git a/test/misc.jl b/test/misc.jl index 0548d9206fb6f..18a004d41ae71 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -76,9 +76,9 @@ end @test GC.enable(true) # PR #10984 -# Disable on windows because of issue (missing flush) when redirecting stderr. +# Disable on windows because of issue (missing flush) when redirecting STDERR. let - redir_err = "redirect_stderr(stdout)" + redir_err = "redirect_stderr(STDOUT)" exename = Base.julia_cmd() script = "$redir_err; module A; f() = 1; end; A.f() = 1" warning_str = read(`$exename --warn-overwrite=yes --startup-file=no -e $script`, String) @@ -437,14 +437,14 @@ let buf_color = IOBuffer() @test String(take!(buf_color)) == "\e[31m\e[1mTwo\e[22m\e[39m\n\e[31m\e[1mlines\e[22m\e[39m" end -if stdout isa Base.TTY - @test haskey(stdout, :color) == true - @test haskey(stdout, :bar) == false - @test (:color=>Base.have_color) in stdout - @test (:color=>!Base.have_color) ∉ stdout - @test stdout[:color] == get(stdout, :color, nothing) == Base.have_color - @test get(stdout, :bar, nothing) === nothing - @test_throws KeyError stdout[:bar] +if STDOUT isa Base.TTY + @test haskey(STDOUT, :color) == true + @test haskey(STDOUT, :bar) == false + @test (:color=>Base.have_color) in STDOUT + @test (:color=>!Base.have_color) ∉ STDOUT + @test STDOUT[:color] == get(STDOUT, :color, nothing) == Base.have_color + @test get(STDOUT, :bar, nothing) === nothing + @test_throws KeyError STDOUT[:bar] end let @@ -582,7 +582,7 @@ include("testenv.jl") let flags = Cmd(filter(a->!occursin("depwarn", a), collect(test_exeflags))) local cmd = `$test_exename $flags deprecation_exec.jl` - if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) + if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("Deprecation test failed, cmd : $cmd") end end diff --git a/test/ranges.jl b/test/ranges.jl index c0ebdeee04c6e..c62f281e1ad52 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -906,7 +906,7 @@ end @testset "repr" begin # repr/show should display the range nicely # to test print_range in range.jl - replrepr(x) = repr("text/plain", x; context=IOContext(stdout, :limit=>true, :displaysize=>(24, 80))) + replrepr(x) = repr("text/plain", x; context=IOContext(STDOUT, :limit=>true, :displaysize=>(24, 80))) @test replrepr(1:4) == "1:4" @test repr("text/plain", 1:4) == "1:4" @test repr("text/plain", range(1, stop=5, length=7)) == "1.0:0.6666666666666666:5.0" diff --git a/test/read.jl b/test/read.jl index e2e73fbe62e51..3e1d2c208a925 100644 --- a/test/read.jl +++ b/test/read.jl @@ -399,17 +399,17 @@ end test_read_nbyte() -# devnull -@test !isreadable(devnull) -@test iswritable(devnull) -@test isopen(devnull) -@test write(devnull, 0xff) === 1 -@test write(devnull, Int32(1234)) === 4 -@test_throws EOFError read(devnull, UInt8) -@test close(devnull) === nothing -@test flush(devnull) === nothing -@test eof(devnull) -@test print(devnull, "go to /dev/null") === nothing +# DevNull +@test !isreadable(DevNull) +@test iswritable(DevNull) +@test isopen(DevNull) +@test write(DevNull, 0xff) === 1 +@test write(DevNull, Int32(1234)) === 4 +@test_throws EOFError read(DevNull, UInt8) +@test close(DevNull) === nothing +@test flush(DevNull) === nothing +@test eof(DevNull) +@test print(DevNull, "go to /dev/null") === nothing let s = "qwerty" diff --git a/test/runtests.jl b/test/runtests.jl index fd3870e06cee3..ac7a4c2ab67e5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -109,11 +109,11 @@ cd(dirname(@__FILE__)) do local stdin_monitor all_tasks = Task[] try - if isa(stdin, Base.TTY) + if isa(STDIN, Base.TTY) t = current_task() - # Monitor stdin and kill this task on ^C + # Monitor STDIN and kill this task on ^C stdin_monitor = @async begin - term = REPL.Terminals.TTYTerminal("xterm", stdin, stdout, stderr) + term = REPL.Terminals.TTYTerminal("xterm", STDIN, STDOUT, STDERR) try REPL.Terminals.raw!(term, true) while true @@ -194,7 +194,7 @@ cd(dirname(@__FILE__)) do foreach(task->try; schedule(task, InterruptException(); error=true); end, all_tasks) foreach(wait, all_tasks) finally - if isa(stdin, Base.TTY) + if isa(STDIN, Base.TTY) schedule(stdin_monitor, InterruptException(); error=true) end end @@ -243,7 +243,7 @@ cd(dirname(@__FILE__)) do Test.pop_testset() elseif isa(res[2][1], RemoteException) && isa(res[2][1].captured.ex, Test.TestSetException) println("Worker $(res[2][1].pid) failed running test $(res[1]):") - Base.showerror(stdout,res[2][1].captured) + Base.showerror(STDOUT,res[2][1].captured) fake = Test.DefaultTestSet(res[1]) for i in 1:res[2][1].captured.ex.pass Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) diff --git a/test/show.jl b/test/show.jl index 307f576a7fb94..741a7df08cb1c 100644 --- a/test/show.jl +++ b/test/show.jl @@ -480,15 +480,15 @@ end @test_repr "Array{<:Real}" @test_repr "Array{>:Real}" -let oldout = stdout, olderr = stderr +let oldout = STDOUT, olderr = STDERR local rdout, wrout, rderr, wrerr, out, err, rd, wr, io try # pr 16917 rdout, wrout = redirect_stdout() - @test wrout === stdout + @test wrout === STDOUT out = @async read(rdout, String) rderr, wrerr = redirect_stderr() - @test wrerr === stderr + @test wrerr === STDERR err = @async read(rderr, String) @test dump(Int64) === nothing if !Sys.iswindows() @@ -496,7 +496,7 @@ let oldout = stdout, olderr = stderr close(wrerr) end - for io in (Core.stdout, Core.stderr) + for io in (Core.STDOUT, Core.STDERR) Core.println(io, "TESTA") println(io, "TESTB") print(io, 'Α', 1) @@ -531,7 +531,7 @@ let filename = tempname() @test chomp(read(filename, String)) == "hello" ret = open(filename, "w") do f redirect_stderr(f) do - println(stderr, "WARNING: hello") + println(STDERR, "WARNING: hello") [2] end end diff --git a/test/spawn.jl b/test/spawn.jl index 93e16ed435592..e8dcb14a9a541 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -55,12 +55,12 @@ out = read(`$echocmd hello` & `$echocmd world`, String) @test (run(`$printfcmd " \033[34m[stdio passthrough ok]\033[0m\n"`); true) # Test for SIGPIPE being treated as normal termination (throws an error if broken) -Sys.isunix() && run(pipeline(yescmd, `head`, devnull)) +Sys.isunix() && run(pipeline(yescmd, `head`, DevNull)) let a, p a = Base.Condition() @schedule begin - p = run(pipeline(yescmd,devnull), wait=false) + p = run(pipeline(yescmd,DevNull), wait=false) Base.notify(a,p) @test !success(p) end @@ -93,7 +93,7 @@ end @test_broken success(ignorestatus(pipeline(falsecmd, falsecmd))) @test_broken success(ignorestatus(falsecmd & falsecmd)) -# stdin Redirection +# STDIN Redirection let file = tempname() run(pipeline(`$echocmd hello world`, file)) @test read(pipeline(file, catcmd), String) == "hello world\n" @@ -215,16 +215,16 @@ exename = Base.julia_cmd() if valgrind_off # If --trace-children=yes is passed to valgrind, we will get a # valgrind banner here, not "Hello World\n". - @test read(pipeline(`$exename --startup-file=no -e 'println(stderr,"Hello World")'`, stderr=catcmd), String) == "Hello World\n" + @test read(pipeline(`$exename --startup-file=no -e 'println(STDERR,"Hello World")'`, stderr=catcmd), String) == "Hello World\n" out = Pipe() - proc = run(pipeline(`$exename --startup-file=no -e 'println(stderr,"Hello World")'`, stderr = out), wait=false) + proc = run(pipeline(`$exename --startup-file=no -e 'println(STDERR,"Hello World")'`, stderr = out), wait=false) close(out.in) @test read(out, String) == "Hello World\n" @test success(proc) end # setup_stdio for AbstractPipe -let out = Pipe(), proc = run(pipeline(`$echocmd "Hello World"`, stdout=IOContext(out,stdout)), wait=false) +let out = Pipe(), proc = run(pipeline(`$echocmd "Hello World"`, stdout=IOContext(out,STDOUT)), wait=false) close(out.in) @test read(out, String) == "Hello World\n" @test success(proc) @@ -234,7 +234,7 @@ end @test run(pipeline(ignorestatus(falsecmd), truecmd)) isa Base.AbstractPipe @testset "redirect_*" begin - let OLD_STDOUT = stdout, + let OLD_STDOUT = STDOUT, fname = tempname(), f = open(fname,"w") @@ -243,7 +243,7 @@ end redirect_stdout(OLD_STDOUT) close(f) @test "Hello World\n" == read(fname, String) - @test OLD_STDOUT === stdout + @test OLD_STDOUT === STDOUT rm(fname) end end @@ -260,7 +260,7 @@ let fname = tempname(), p unsafe_store!(convert(Ptr{Cint}, handle + 2 * sizeof(Ptr{Cvoid})), 15) nothing end - OLD_STDERR = stderr + OLD_STDERR = STDERR redirect_stderr(open($(repr(fname)), "w")) # Usually this would be done by GC. Do it manually, to make the failure # case more reliable. @@ -272,7 +272,7 @@ let fname = tempname(), p import Base.zzzInvalidIdentifier """ try - io = open(pipeline(`$exename --startup-file=no`, stderr=stderr), "w") + io = open(pipeline(`$exename --startup-file=no`, stderr=STDERR), "w") write(io, cmd) close(io) wait(io) @@ -292,7 +292,7 @@ let bad = "bad\0name" end # issue #12829 -let out = Pipe(), echo = `$exename --startup-file=no -e 'print(stdout, " 1\t", read(stdin, String))'`, ready = Condition(), t, infd, outfd +let out = Pipe(), echo = `$exename --startup-file=no -e 'print(STDOUT, " 1\t", read(STDIN, String))'`, ready = Condition(), t, infd, outfd @test_throws ArgumentError write(out, "not open error") t = @async begin # spawn writer task open(echo, "w", out) do in1 @@ -369,7 +369,7 @@ let fname = tempname() else "cmd = pipeline(`echo asdf`, `cat`)" end) - for line in eachline(stdin) + for line in eachline(STDIN) run(cmd) end """ @@ -414,7 +414,7 @@ end @test Base.shell_split("\"\\\\\"") == ["\\"] # issue #13616 -@test_throws ErrorException collect(eachline(pipeline(`$catcmd _doesnt_exist__111_`, stderr=devnull))) +@test_throws ErrorException collect(eachline(pipeline(`$catcmd _doesnt_exist__111_`, stderr=DevNull))) # make sure windows_verbatim strips quotes if Sys.iswindows() @@ -504,14 +504,14 @@ end #let out = Pipe(), inpt = Pipe() # Base.link_pipe!(out, reader_supports_async=true) # Base.link_pipe!(inpt, writer_supports_async=true) -# p = run(pipeline(catcmd, stdin=inpt, stdout=out, stderr=devnull), wait=false) +# p = run(pipeline(catcmd, stdin=inpt, stdout=out, stderr=DevNull), wait=false) # @async begin # feed cat with 2 MB of data (zeros) -# write(inpt, zeros(UInt8, 1048576 * 2)) -# close(inpt) +# write(stdin, zeros(UInt8, 1048576 * 2)) +# close(stdin) # end # sleep(0.5) # give cat a chance to fill the write buffer for stdout -# close(out.in) # make sure we can still close the write end -# @test sizeof(readstring(out)) == 1048576 * 2 # make sure we get all the data +# close(stdout.in) # make sure we can still close the write end +# @test sizeof(readstring(stdout)) == 1048576 * 2 # make sure we get all the data # @test success(p) #end diff --git a/test/threads.jl b/test/threads.jl index 7c943265ff2e5..0a28985723acf 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -27,7 +27,7 @@ function test_threaded_loop_and_atomic_add() # and were unique (via pigeon-hole principle). @test !(false in found) if was_inorder - println(stderr, "Warning: threaded loop executed in order") + println(STDERR, "Warning: threaded loop executed in order") end end