Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "slave" variable #30058

Merged
merged 3 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ function generate_precompile_statements()
# Fake being cygwin
pipename = """\\\\?\\pipe\\cygwin-$("0"^16)-pty10-abcdef"""
server = listen(pipename)
slave = connect(pipename)
@assert ccall(:jl_ispty, Cint, (Ptr{Cvoid},), slave.handle) == 1
master = accept(server)
pty_slave = connect(pipename)
@assert ccall(:jl_ispty, Cint, (Ptr{Cvoid},), pty_slave.handle) == 1
pty_master = accept(server)
else
slave, master = open_fake_pty()
pty_slave, pty_master = open_fake_pty()
end
done = false
blackhole = Sys.isunix() ? "/dev/null" : "nul"
Expand All @@ -96,12 +96,12 @@ function generate_precompile_statements()
--compile=all --startup-file=no --color=yes
-e 'import REPL; REPL.Terminals.is_precompiling[] = true'
-i`,
slave, slave, slave; wait=false)
readuntil(master, "julia>", keep=true)
pty_slave, pty_slave, pty_slave; wait=false)
readuntil(pty_master, "julia>", keep=true)
t = @async begin
while true
sleep(0.5)
s = String(readavailable(master))
s = String(readavailable(pty_master))
write(repl_output_buffer, s)
if occursin("__PRECOMPILE_END__", s)
break
Expand All @@ -110,18 +110,18 @@ function generate_precompile_statements()
end
if have_repl
for l in split(precompile_script, '\n'; keepempty=false)
write(master, l, '\n')
write(pty_master, l, '\n')
end
end
write(master, "print(\"__PRECOMPILE\", \"_END__\")", '\n')
write(pty_master, "print(\"__PRECOMPILE\", \"_END__\")", '\n')
wait(t)

# TODO Figure out why exit() on Windows doesn't exit the process
if Sys.iswindows()
print(master, "ccall(:_exit, Cvoid, (Cint,), 0)\n")
print(pty_master, "ccall(:_exit, Cvoid, (Cint,), 0)\n")
else
write(master, "exit()\n")
readuntil(master, "exit()\r\e[13C\r\n")
write(pty_master, "exit()\n")
readuntil(pty_master, "exit()\r\e[13C\r\n")
# @assert bytesavailable(master) == 0
end
wait(p)
Expand All @@ -132,7 +132,7 @@ function generate_precompile_statements()
-e0`)
end
end
close(master)
close(pty_master)

# Check what the REPL displayed
# repl_output = String(take!(repl_output_buffer))
Expand Down
16 changes: 8 additions & 8 deletions stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function challenge_prompt(cmd::Cmd, challenges; timeout::Integer=60, debug::Bool
"Process output found:\n\"\"\"\n$str\n\"\"\""
end
out = IOBuffer()
with_fake_pty() do slave, master
p = run(detach(cmd), slave, slave, slave, wait=false)
with_fake_pty() do pty_slave, pty_master
p = run(detach(cmd), pty_slave, pty_slave, pty_slave, wait=false)

# Kill the process if it takes too long. Typically occurs when process is waiting
# for input.
Expand All @@ -75,21 +75,21 @@ function challenge_prompt(cmd::Cmd, challenges; timeout::Integer=60, debug::Bool
process_running(p) && kill(p, Base.SIGKILL)
end

close(master)
close(pty_master)
end

for (challenge, response) in challenges
write(out, readuntil(master, challenge, keep=true))
if !isopen(master)
write(out, readuntil(pty_master, challenge, keep=true))
if !isopen(pty_master)
error("Could not locate challenge: \"$challenge\". ",
format_output(out))
end
write(master, response)
write(pty_master, response)
end

# Capture output from process until `master` is closed
while !eof(master)
write(out, readavailable(master))
while !eof(pty_master)
write(out, readavailable(pty_master))
end

status = fetch(timer)
Expand Down
12 changes: 6 additions & 6 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -729,22 +729,22 @@ ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 1)
let exename = Base.julia_cmd()
# Test REPL in dumb mode
if !Sys.iswindows()
with_fake_pty() do slave, master
with_fake_pty() do pty_slave, pty_master
nENV = copy(ENV)
nENV["TERM"] = "dumb"
p = run(setenv(`$exename --startup-file=no -q`,nENV),slave,slave,slave,wait=false)
output = readuntil(master,"julia> ",keep=true)
p = run(setenv(`$exename --startup-file=no -q`,nENV),pty_slave,pty_slave,pty_slave,wait=false)
output = readuntil(pty_master,"julia> ",keep=true)
if ccall(:jl_running_on_valgrind,Cint,()) == 0
# If --trace-children=yes is passed to valgrind, we will get a
# valgrind banner here, not just the prompt.
@test output == "julia> "
end
write(master,"1\nexit()\n")
write(pty_master,"1\nexit()\n")

wait(p)
output = readuntil(master,' ',keep=true)
output = readuntil(pty_master,' ',keep=true)
@test output == "1\r\nexit()\r\n1\r\n\r\njulia> "
@test bytesavailable(master) == 0
@test bytesavailable(pty_master) == 0
end
end

Expand Down