Skip to content

Commit

Permalink
Add a test for the dumb REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed May 24, 2014
1 parent e9996b1 commit c64db18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TESTS = all core keywordargs numbers strings unicode collections hashing \
git pkg resolve suitesparse complex version pollfd mpfr broadcast \
socket floatapprox priorityqueue readdlm regex float16 combinatorics \
sysinfo rounding ranges mod2pi euler show linalg1 linalg2 linalg3 lineedit \
replcompletions backtrace
replcompletions backtrace repl

default: all

Expand Down
26 changes: 15 additions & 11 deletions test/repl.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# REPL tests
let exename=joinpath(JULIA_HOME,(ccall(:jl_is_debugbuild,Cint,())==0?"julia":"julia-debug"))

# Test REPL in dumb mode
@unix_only begin

exename=joinpath(JULIA_HOME,(ccall(:jl_is_debugbuild,Cint,())==0?"julia":"julia-debug"))

const O_RDWR = Base.FS.JL_O_RDWR
const O_NOCTTY = 0x20000

Expand All @@ -17,24 +17,28 @@ rc != 0 && error("unlockpt")
fds = ccall(:open,Cint,(Ptr{Uint8},Cint),ccall(:ptsname,Ptr{Uint8},(Cint,),fdm), O_RDWR)

# slave
slaveSTDIN = Base.TTY(RawFD(fds); readable = true)
slaveSTDERR = Base.TTY(RawFD(fds))
slaveSTDOUT = Base.TTY(RawFD(fds))
slave = Base.TTY(RawFD(fds); readable = true)
master = Base.TTY(RawFD(fdm); readable = true)

# First test REPL in dumb mode
nENV = copy(ENV)
nENV["TERM"] = "dumb"
p = spawn(setenv(`$exename --quiet`,nENV),slaveSTDIN,slaveSTDOUT,slaveSTDERR)
p = spawn(setenv(`$exename --quiet`,nENV),slave,slave,slave)
start_reading(master)
Base.wait_readnb(master,1)
write(master,"1\nquit()\n")

wait(p)

@test readavailable(master) == "julia> 1\r\nquit()\r\n1\r\n\r\njulia> "
output = readavailable(master)
@test output == "julia> 1\r\nquit()\r\n1\r\n\r\njulia> "

close(slave)
close(master)
close(slaveSTDIN)
close(slaveSTDOUT)
close(slaveSTDERR)

end

# Test stream mode
outs, ins, p = readandwrite(`$exename --quiet`)
write(ins,"1\nquit()\n")
@test readall(outs) == "1\n"
end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ testnames = [
"resolve", "pollfd", "mpfr", "broadcast", "complex", "socket",
"floatapprox", "readdlm", "regex", "float16", "combinatorics",
"sysinfo", "rounding", "ranges", "mod2pi", "euler", "show",
"lineedit", "replcompletions"
"lineedit", "replcompletions", "repl"
]
@unix_only push!(testnames, "unicode")

Expand All @@ -35,7 +35,7 @@ end
n = 1
if net_on
n = min(8, CPU_CORES, length(tests))
n > 1 && addprocs(n)
n > 0 && addprocs(n)
blas_set_num_threads(1)
else
filter!(x -> !(x in net_required_for), tests)
Expand Down

0 comments on commit c64db18

Please sign in to comment.