@@ -4,6 +4,8 @@ import Pkg: PackageSpec
44
55import BinaryBuilder. BinaryBuilderBase: available_gcc_builds, available_llvm_builds, getversion
66
7+ const debug = Ref (false )
8+
79function with_wizard_output (f:: Function , state, step_func:: Function )
810 # Create fake terminal to communicate with BinaryBuilder over
911 pty = VT100. create_pty (false )
@@ -17,7 +19,7 @@ function with_wizard_output(f::Function, state, step_func::Function)
1719 z = String (readavailable (pty. master))
1820
1921 # Un-comment this to figure out what on earth is going wrong
20- # print(z)
22+ debug[] && print (z)
2123 write (out_buff, z)
2224 end
2325 end
@@ -110,14 +112,37 @@ function readuntil_sift(io::IO, needle)
110112end
111113
112114function 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))
114118 # Because we occasionally are dealing with things that do strange
115119 # stdin tricks like reading raw stdin buffers, we sleep here for safety.
116120 sleep (0.1 )
121+ if debug[]
122+ print (answer)
123+ newline && println ()
124+ end
117125 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]"
120141 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
121146end
122147
123148@testset " Wizard - Obtain source" begin
@@ -321,19 +346,6 @@ function step3_test(state)
321346end
322347
323348@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-
337349 # Test step3 success path
338350 state = step3_state ()
339351 with_wizard_output (state, Wizard. step34) do ins, outs
0 commit comments