@@ -4,6 +4,8 @@ import Pkg: PackageSpec
4
4
5
5
import BinaryBuilder. BinaryBuilderBase: available_gcc_builds, available_llvm_builds, getversion
6
6
7
+ const debug = Ref (false )
8
+
7
9
function with_wizard_output (f:: Function , state, step_func:: Function )
8
10
# Create fake terminal to communicate with BinaryBuilder over
9
11
pty = VT100. create_pty (false )
@@ -17,7 +19,7 @@ function with_wizard_output(f::Function, state, step_func::Function)
17
19
z = String (readavailable (pty. master))
18
20
19
21
# Un-comment this to figure out what on earth is going wrong
20
- # print(z)
22
+ debug[] && print (z)
21
23
write (out_buff, z)
22
24
end
23
25
end
@@ -110,14 +112,37 @@ function readuntil_sift(io::IO, needle)
110
112
end
111
113
112
114
function call_response (ins, outs, question, answer; newline= true )
113
- @assert readuntil_sift (outs, question) != = nothing
115
+ buf = readuntil_sift (outs, question)
116
+ @assert buf != = nothing
117
+ debug[] && println (String (buf))
114
118
# Because we occasionally are dealing with things that do strange
115
119
# stdin tricks like reading raw stdin buffers, we sleep here for safety.
116
120
sleep (0.1 )
121
+ if debug[]
122
+ print (answer)
123
+ newline && println ()
124
+ end
117
125
print (ins, answer)
118
- if newline
119
- println (ins)
126
+ newline && println (ins)
127
+ end
128
+
129
+ function succcess_path_call_response (ins, outs)
130
+ output = readuntil_sift (outs, " Build complete" )
131
+ if contains (String (output), " Warning:" )
132
+ close (ins)
133
+ return false
134
+ end
135
+ call_response (ins, outs, " Would you like to edit this script now?" , " N" )
136
+ # MultiSelectMenu (https://docs.julialang.org/en/v1/stdlib/REPL/#MultiSelectMenu)
137
+ needle = if VERSION < v " 1.9"
138
+ " [press: d=done, a=all, n=none]"
139
+ else
140
+ " [press: Enter=toggle, a=all, n=none, d=done, q=abort]"
120
141
end
142
+ call_response (ins, outs, needle, " ad" ; newline= false )
143
+ call_response (ins, outs, " lib/libfoo.so" , " libfoo" )
144
+ call_response (ins, outs, " bin/fooifier" , " fooifier" )
145
+ return true
121
146
end
122
147
123
148
@testset " Wizard - Obtain source" begin
@@ -321,19 +346,6 @@ function step3_test(state)
321
346
end
322
347
323
348
@testset " Wizard - Building" begin
324
- function succcess_path_call_response (ins, outs)
325
- output = readuntil_sift (outs, " Build complete" )
326
- if contains (String (output), " Warning:" )
327
- close (ins)
328
- return false
329
- end
330
- call_response (ins, outs, " Would you like to edit this script now?" , " N" )
331
- call_response (ins, outs, " d=done, a=all" , " ad" ; newline= false )
332
- call_response (ins, outs, " lib/libfoo.so" , " libfoo" )
333
- call_response (ins, outs, " bin/fooifier" , " fooifier" )
334
- return true
335
- end
336
-
337
349
# Test step3 success path
338
350
state = step3_state ()
339
351
with_wizard_output (state, Wizard. step34) do ins, outs
0 commit comments