Skip to content

Commit

Permalink
fix next prompt detector in generate_precompile_statements (#44196)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Feb 16, 2022
1 parent 983598a commit c839221
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ if Profile !== nothing
"""
end

const JULIA_PROMPT = "julia> "
const PKG_PROMPT = "pkg> "
const SHELL_PROMPT = "shell> "
const HELP_PROMPT = "help?> "

function generate_precompile_statements()
start_time = time_ns()
debug_output = devnull # or stdout
Expand Down Expand Up @@ -311,7 +316,7 @@ function generate_precompile_statements()
close(ptm)
end
# wait for the definitive prompt before start writing to the TTY
readuntil(output_copy, "julia>")
readuntil(output_copy, JULIA_PROMPT)
sleep(0.1)
readavailable(output_copy)
# Input our script
Expand All @@ -329,9 +334,16 @@ function generate_precompile_statements()
write(ptm, l, "\n")
readuntil(output_copy, "\n")
# wait for the next prompt-like to appear
# NOTE: this is rather inaccurate because the Pkg REPL mode is a special flower
readuntil(output_copy, "\n")
readuntil(output_copy, "> ")
strbuf = ""
while true
strbuf *= String(readavailable(output_copy))
occursin(JULIA_PROMPT, strbuf) && break
occursin(PKG_PROMPT, strbuf) && break
occursin(SHELL_PROMPT, strbuf) && break
occursin(HELP_PROMPT, strbuf) && break
sleep(0.1)
end
end
println()
end
Expand Down

0 comments on commit c839221

Please sign in to comment.