@@ -24,7 +24,8 @@ function repl_workload()
24
24
function check_errors (out)
25
25
str = String (out)
26
26
if occursin (" ERROR:" , str) && ! any (occursin (e, str) for e in allowed_errors)
27
- @error " Unexpected error (Review REPL precompilation with debug_output on):\n $str "
27
+ @error " Unexpected error (Review REPL precompilation with debug_output on):\n $str " exception= (
28
+ Base. PrecompilableError (), Base. backtrace ())
28
29
exit (1 )
29
30
end
30
31
end
@@ -40,6 +41,7 @@ function repl_workload()
40
41
41
42
# This is notified as soon as the first prompt appears
42
43
repl_init_event = Base. Event ()
44
+ repl_init_done_event = Base. Event ()
43
45
44
46
atreplinit () do repl
45
47
# Main is closed so we can't evaluate in it, but atreplinit runs at
@@ -48,6 +50,7 @@ function repl_workload()
48
50
t = @async begin
49
51
wait (repl_init_event)
50
52
REPL. activate (REPL. Precompile; interactive_utils= false )
53
+ notify (repl_init_done_event)
51
54
end
52
55
Base. errormonitor (t)
53
56
end
@@ -80,6 +83,9 @@ function repl_workload()
80
83
"""
81
84
82
85
JULIA_PROMPT = " julia> "
86
+ # The help text for `reinterpret` has example `julia>` prompts in it,
87
+ # so use the longer prompt to avoid desychronization.
88
+ ACTIVATED_JULIA_PROMPT = " (REPL.Precompile) julia> "
83
89
PKG_PROMPT = " pkg> "
84
90
SHELL_PROMPT = " shell> "
85
91
HELP_PROMPT = " help?> "
@@ -142,18 +148,24 @@ function repl_workload()
142
148
end
143
149
schedule (repltask)
144
150
# wait for the definitive prompt before start writing to the TTY
145
- check_errors (readuntil (output_copy, JULIA_PROMPT))
151
+ check_errors (readuntil (output_copy, JULIA_PROMPT, keep= true ))
152
+
153
+ # Switch to the activated prompt
154
+ notify (repl_init_event)
155
+ wait (repl_init_done_event)
156
+ write (ptm, " \n " )
157
+ # The prompt prints twice - once for the restatement of the input, once
158
+ # to indicate ready for the new prompt.
159
+ check_errors (readuntil (output_copy, ACTIVATED_JULIA_PROMPT, keep= true ))
160
+ check_errors (readuntil (output_copy, ACTIVATED_JULIA_PROMPT, keep= true ))
161
+
146
162
write (debug_output, " \n #### REPL STARTED ####\n " )
147
- sleep (0.01 )
148
- check_errors (readavailable (output_copy))
149
163
# Input our script
150
164
precompile_lines = split (repl_script:: String , ' \n ' ; keepempty= false )
151
165
curr = 0
152
166
for l in precompile_lines
153
167
sleep (0.01 ) # try to let a bit of output accumulate before reading again
154
168
curr += 1
155
- # consume any other output
156
- bytesavailable (output_copy) > 0 && check_errors (readavailable (output_copy))
157
169
# push our input
158
170
write (debug_output, " \n #### inputting statement: ####\n $(repr (l)) \n ####\n " )
159
171
# If the line ends with a CTRL_C, don't write an extra newline, which would
@@ -166,13 +178,12 @@ function repl_workload()
166
178
strbuf = " "
167
179
while ! eof (output_copy)
168
180
strbuf *= String (readavailable (output_copy))
169
- occursin (JULIA_PROMPT , strbuf) && break
181
+ occursin (ACTIVATED_JULIA_PROMPT , strbuf) && break
170
182
occursin (PKG_PROMPT, strbuf) && break
171
183
occursin (SHELL_PROMPT, strbuf) && break
172
184
occursin (HELP_PROMPT, strbuf) && break
173
185
sleep (0.01 ) # try to let a bit of output accumulate before reading again
174
186
end
175
- notify (repl_init_event)
176
187
check_errors (strbuf)
177
188
end
178
189
write (debug_output, " \n #### COMPLETED - Closing REPL ####\n " )
0 commit comments