Skip to content

Commit

Permalink
Fix tests sensitive to --color=yes (#39286)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Jan 18, 2021
1 parent 29f2f89 commit 054caaa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,12 @@ end

Base.exit_on_sigint(true)

let exename = Base.julia_cmd()
let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
# Test REPL in dumb mode
with_fake_pty() do pts, ptm
nENV = copy(ENV)
nENV["TERM"] = "dumb"
p = run(detach(setenv(`$exename --startup-file=no -q`, nENV)), pts, pts, pts, wait=false)
p = run(detach(setenv(`$exename -q`, nENV)), pts, pts, pts, wait=false)
Base.close_stdio(pts)
output = readuntil(ptm, "julia> ", keep=true)
if ccall(:jl_running_on_valgrind, Cint,()) == 0
Expand Down Expand Up @@ -827,7 +827,7 @@ let exename = Base.julia_cmd()
end

# Test stream mode
p = open(`$exename --startup-file=no -q`, "r+")
p = open(`$exename -q`, "r+")
write(p, "1\nexit()\n")
@test read(p, String) == "1\n"
end # let exename
Expand Down
3 changes: 2 additions & 1 deletion test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,8 @@ end

# issue #34061
let o_file = tempname(), err = Base.PipeEndpoint()
run(pipeline(Cmd(`$(Base.julia_cmd()) --output-o=$o_file -e 'Base.reinit_stdio();
run(pipeline(Cmd(`$(Base.julia_cmd()) --color=no --output-o=$o_file -e '
Base.reinit_stdio();
f() = ccall((:dne, :does_not_exist), Cvoid, ());
f()'`; ignorestatus=true), stderr=err), wait=false)
output = read(err, String)
Expand Down
10 changes: 5 additions & 5 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let
@test format_filename("%a%%b") == "a%b"
end

let exename = `$(Base.julia_cmd()) --startup-file=no`
let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
# tests for handling of ENV errors
let v = writereadpipeline("println(\"REPL: \", @which(less), @isdefined(InteractiveUtils))",
setenv(`$exename -i -E 'empty!(LOAD_PATH); @isdefined InteractiveUtils'`,
Expand Down Expand Up @@ -94,7 +94,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
end
end

let exename = `$(Base.julia_cmd()) --startup-file=no`
let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
# --version
let v = split(read(`$exename -v`, String), "julia version ")[end]
@test Base.VERSION_STRING == chomp(v)
Expand Down Expand Up @@ -673,7 +673,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
end

# issue #6310
let exename = `$(Base.julia_cmd()) --startup-file=no`
let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test writereadpipeline("2+2", exename) == ("4\n", true)
@test writereadpipeline("2+2\n3+3\n4+4", exename) == ("4\n6\n8\n", true)
@test writereadpipeline("", exename) == ("", true)
Expand All @@ -698,7 +698,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
end

# incomplete inputs to stream REPL
let exename = `$(Base.julia_cmd()) --startup-file=no`
let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
in = Pipe(); out = Pipe(); err = Pipe()
proc = run(pipeline(exename, stdin = in, stdout = out, stderr = err), wait=false)
write(in, "f(\n")
Expand All @@ -710,7 +710,7 @@ end

# Issue #29855
for yn in ("no", "yes")
exename = `$(Base.julia_cmd()) --inline=no --startup-file=no --inline=$yn`
exename = `$(Base.julia_cmd()) --inline=no --startup-file=no --color=no --inline=$yn`
v = writereadpipeline("Base.julia_cmd()", exename)
if yn == "no"
@test occursin(r" --inline=no", v[1])
Expand Down
2 changes: 1 addition & 1 deletion test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ include_string_test_func = include_string(@__MODULE__, "include_string_test() =
@test isdir(@__DIR__)
@test @__DIR__() == dirname(@__FILE__)
@test !endswith(@__DIR__, Base.Filesystem.path_separator)
let exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no`,
let exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no --color=no`,
wd = sprint(show, pwd())
s_dir = sprint(show, realpath(tempdir()))
@test wd != s_dir
Expand Down
20 changes: 10 additions & 10 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,21 @@ let r, t, sock
end

# issue #4535
exename = Base.julia_cmd()
exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
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 -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 -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(`$exename --startup-file=no -e 'println(getpid())'`, stdout=IOContext(out, :foo => :bar)), wait=false)
proc = run(pipeline(`$exename -e 'println(getpid())'`, stdout=IOContext(out, :foo => :bar)), wait=false)
# < don't block here before getpid call >
pid = getpid(proc)
close(out.in)
Expand Down Expand Up @@ -298,7 +298,7 @@ let fname = tempname(), p
import Base.zzzInvalidIdentifier
"""
try
io = open(pipeline(`$exename --startup-file=no`, stderr=stderr), "w")
io = open(pipeline(exename, stderr=stderr), "w")
write(io, cmd)
close(io)
wait(io)
Expand All @@ -318,7 +318,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 -e 'print(stdout, " 1\t", read(stdin, String))'`, ready = Condition(), t, infd, outfd
@test_throws ArgumentError write(out, "not open error")
inread = false
t = @async begin # spawn writer task
Expand Down Expand Up @@ -399,7 +399,7 @@ let fname = tempname()
run(cmd)
end
"""
@test success(pipeline(`$catcmd $fname`, `$exename --startup-file=no -e $code`))
@test success(pipeline(`$catcmd $fname`, `$exename -e $code`))
rm(fname)
end

Expand Down Expand Up @@ -520,7 +520,7 @@ end

# issue #19864 (PR #20497)
let c19864 = readchomp(pipeline(ignorestatus(
`$exename --startup-file=no -e '
`$exename -e '
struct Error19864 <: Exception; end
Base.showerror(io::IO, e::Error19864) = print(io, "correct19864")
throw(Error19864())'`),
Expand Down Expand Up @@ -573,7 +573,7 @@ end

# Logging macros should not output to finalized streams (#26687)
let
cmd = `$exename --startup-file=no -e 'finalizer(x->@info(x), "Hello")'`
cmd = `$exename -e 'finalizer(x->@info(x), "Hello")'`
output = readchomp(pipeline(cmd, stderr=catcmd))
@test occursin("Info: Hello", output)
end
Expand Down Expand Up @@ -686,7 +686,7 @@ end

let text = "input-test-text"
b = PipeBuffer()
proc = open(Base.CmdRedirect(Base.CmdRedirect(```$exename --startup-file=no -E '
proc = open(Base.CmdRedirect(Base.CmdRedirect(```$exename -E '
in14 = Base.open(RawFD(14))
out15 = Base.open(RawFD(15))
write(out15, in14)'```,
Expand Down

0 comments on commit 054caaa

Please sign in to comment.