Skip to content

Commit

Permalink
Deprecate DevNull to DEVNULL
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Feb 8, 2018
1 parent e5aab06 commit 4a12fad
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 81 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ 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]).

* The constant `DevNull` has been deprecated in favor of `DEVNULL` ([#25786]).

Command-line option changes
---------------------------

Expand Down Expand Up @@ -1285,3 +1287,4 @@ Command-line option changes
[#25654]: https://github.com/JuliaLang/julia/issues/25654
[#25655]: https://github.com/JuliaLang/julia/issues/25655
[#25745]: https://github.com/JuliaLang/julia/issues/25745
[#25786]: https://github.com/JuliaLang/julia/issues/25786
2 changes: 1 addition & 1 deletion base/clipboard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions base/coreio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
Expand All @@ -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
STDIN = DEVNULL
STDOUT = Core.STDOUT
STDERR = Core.STDERR
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,9 @@ end
# PR #23332
@deprecate ^(x, p::Integer) Base.power_by_squaring(x,p)

# Issue 25786
@deprecate_binding DevNull DEVNULL

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
6 changes: 3 additions & 3 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -790,16 +790,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

Expand Down
2 changes: 1 addition & 1 deletion base/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export
DenseMatrix,
DenseVecOrMat,
DenseVector,
DevNull,
DEVNULL,
Dict,
Dims,
Enum,
Expand Down
24 changes: 12 additions & 12 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
new(filename, append)
end
Expand Down Expand Up @@ -316,13 +316,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)),
Expand Down Expand Up @@ -539,12 +539,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
Expand All @@ -567,7 +567,7 @@ function eachline(cmd::AbstractCmd; chomp=nothing, keep::Bool=false)
depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline)
end
stdout = Pipe()
processes = spawn(cmd, (DevNull,stdout,STDERR))
processes = spawn(cmd, (DEVNULL,stdout,STDERR))
close(stdout.in)
out = stdout.out
# implicitly close after reading lines, since we opened
Expand All @@ -577,17 +577,17 @@ end

# return a Process object to read-to/write-from the pipeline
"""
open(command, mode::AbstractString="r", stdio=DevNull)
open(command, mode::AbstractString="r", stdio=DEVNULL)
Start running `command` asynchronously, and return a tuple `(stream,process)`. If `mode` is
`"r"`, then `stream` reads from the process's standard output and `stdio` optionally
specifies the process's standard input stream. If `mode` is `"w"`, then `stream` writes to
the process's standard input and `stdio` optionally specifies the process's standard output
stream.
"""
function open(cmds::AbstractCmd, mode::AbstractString="r", other::Redirectable=DevNull)
function open(cmds::AbstractCmd, mode::AbstractString="r", other::Redirectable=DEVNULL)
if mode == "r+" || mode == "w+"
other === DevNull || throw(ArgumentError("no other stream for mode rw+"))
other === DEVNULL || throw(ArgumentError("no other stream for mode rw+"))
in = Pipe()
out = Pipe()
processes = spawn(cmds, (in,out,STDERR))
Expand Down Expand Up @@ -620,7 +620,7 @@ function open(cmds::AbstractCmd, mode::AbstractString="r", other::Redirectable=D
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.
Expand All @@ -641,7 +641,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
Expand Down
2 changes: 1 addition & 1 deletion doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Base.skipmissing
```@docs
Base.run
Base.spawn
Base.DevNull
Base.DEVNULL
Base.success
Base.process_running
Base.process_exited
Expand Down
2 changes: 1 addition & 1 deletion examples/embedding/embedding-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end
@testset "embedding example" begin
stdout = Pipe()
stderr = Pipe()
p = spawn(pipeline(Cmd(ARGS), stdin=DevNull, stdout=stdout, stderr=stderr))
p = spawn(pipeline(Cmd(ARGS), stdin=DEVNULL, stdout=stdout, stderr=stderr))
close(stdout.in)
close(stderr.in)
stdout_task = @async readlines(stdout)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,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
Expand Down
6 changes: 3 additions & 3 deletions stdlib/Logging/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,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
Expand Down
10 changes: 5 additions & 5 deletions stdlib/Test/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 !contains(msg, "do_test(")
Expand Down Expand Up @@ -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 contains(msg,
"""
Test Summary: | Pass Fail Total
Expand All @@ -608,7 +608,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

Expand Down Expand Up @@ -645,7 +645,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 contains(msg, "at " * f * ":" * "3")
@test contains(msg, "at " * f * ":" * "4")
@test contains(msg, "at " * f * ":" * "5")
Expand All @@ -656,7 +656,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
Expand Down
4 changes: 2 additions & 2 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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: the type of argument 1 doesn't correspond to a C type"),
f21104at(Float64))
@test_throws(ErrorException("ccall: return type doesn't correspond to a C type"),
Expand Down
6 changes: 3 additions & 3 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ 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_throws ErrorException run(pipeline(DevNull, pipeline(`$(joinpath(Sys.BINDIR,
Base.julia_exename())) -Cnative --lisp`, stderr=DevNull), DevNull))
@test_throws ErrorException run(pipeline(DEVNULL, pipeline(`$(joinpath(Sys.BINDIR,
Base.julia_exename())) -Cnative --lisp`, stderr=DEVNULL), DEVNULL))

# --sysimage-native-code={yes|no}
let exename = `$(Base.julia_cmd()) --startup-file=no`
Expand Down
6 changes: 3 additions & 3 deletions test/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 4a12fad

Please sign in to comment.