From 4b17e28d5d40df23dcf9b727ba3abdce41256046 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 19 Jun 2018 15:32:17 -0700 Subject: [PATCH] Allow any AbstractCmd in read --- README.md | 2 +- src/Compat.jl | 2 +- test/runtests.jl | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21d6785a7..30424d35d 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,7 @@ Currently, the `@compat` macro supports the following syntaxes: * `readstring` is replaced by methods of `read`. ([#22864]) `read(::IO, ::Type{String})`, `read(::AbstractString, ::Type{String})`, - and `read(::Cmd, ::Type{String})` are defined for 0.6 and below. + and `read(::AbstractCmd, ::Type{String})` are defined for 0.6 and below. * `Range` is now `AbstractRange` ([#23570]) diff --git a/src/Compat.jl b/src/Compat.jl index fb7b77da5..ea984393c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -470,7 +470,7 @@ end if VERSION < v"0.7.0-DEV.1053" Base.read(obj::IO, ::Type{String}) = readstring(obj) Base.read(obj::AbstractString, ::Type{String}) = readstring(obj) - Base.read(obj::Cmd, ::Type{String}) = readstring(obj) + Base.read(obj::Base.AbstractCmd, ::Type{String}) = readstring(obj) end # https://github.com/JuliaLang/julia/pull/20005 diff --git a/test/runtests.jl b/test/runtests.jl index cdeb89103..6acd0fc26 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -748,7 +748,10 @@ no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2) # 0.7 @test read(IOBuffer("aaaa"), String) == "aaaa" @test occursin("read(@__FILE__, String)", read(@__FILE__, String)) -@test read(`$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"`, String) == "aaaa\n" +let cmd = `$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"` + @test read(cmd, String) == "aaaa\n" + @test read(pipeline(cmd, stderr=devnull), String) == "aaaa\n" +end # 0.7 @test isa(1:2, AbstractRange)