Skip to content

Commit f7d0176

Browse files
committed
bump coverage
1 parent 515bf75 commit f7d0176

File tree

1 file changed

+165
-115
lines changed

1 file changed

+165
-115
lines changed

test/wizard.jl

Lines changed: 165 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,12 @@ end
281281
end
282282
end
283283

284-
285-
286284
# Dump the tarball to disk so that we can use it directly in the future
287285
tempspace = tempname()
288286
mkdir(tempspace)
289287
libfoo_tarball_path = joinpath(tempspace, "source.tar.gz")
290288
open(f -> write(f, libfoo_tarball_data), libfoo_tarball_path, "w")
291289

292-
293-
294290
function step3_state()
295291
state = Wizard.WizardState()
296292
state.step = :step34
@@ -314,10 +310,10 @@ function step3_test(state)
314310

315311
libfoo_idx = findfirst(state.files .== "lib/libfoo.so")
316312
fooifier_idx = findfirst(state.files .== "bin/fooifier")
317-
@test state.file_kinds[libfoo_idx] == :library
318-
@test state.file_kinds[fooifier_idx] == :executable
319-
@test state.file_varnames[libfoo_idx] == :libfoo
320-
@test state.file_varnames[fooifier_idx] == :fooifier
313+
@test state.file_kinds[libfoo_idx] === :library
314+
@test state.file_kinds[fooifier_idx] === :executable
315+
@test state.file_varnames[libfoo_idx] === :libfoo
316+
@test state.file_varnames[fooifier_idx] === :fooifier
321317
end
322318

323319
@testset "Wizard - Building" begin
@@ -334,116 +330,135 @@ end
334330
return true
335331
end
336332

337-
# Test step3 success path
338-
state = step3_state()
339-
with_wizard_output(state, Wizard.step34) do ins, outs
340-
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
341-
cd libfoo
333+
@testset "Test step3 success path" begin
334+
state = step3_state()
335+
with_wizard_output(state, Wizard.step34) do ins, outs
336+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
337+
make install
338+
exit
339+
""")
340+
@test succcess_path_call_response(ins, outs)
341+
end
342+
@test state.history == """
343+
cd \$WORKSPACE/srcdir
342344
make install
343345
exit
344-
""")
345-
@test succcess_path_call_response(ins, outs)
346+
"""
347+
step3_test(state)
346348
end
347-
@test state.history == """
348-
cd \$WORKSPACE/srcdir
349-
cd libfoo
350-
make install
351-
exit
352-
"""
353-
step3_test(state)
354-
355-
# Step 3 failure path (no binary in destdir -> return to build)
356-
state = step3_state()
357-
with_wizard_output(state, Wizard.step34) do ins, outs
358-
# Don't build anything
359-
call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit")
360-
call_response(ins, outs, "Would you like to edit this script now?", "N")
361349

362-
# Return to build environment
363-
call_response(ins, outs, "Return to build environment", "\r", newline=false)
364-
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
365-
cd libfoo
350+
@testset "Step 3 failure path (no binary in destdir -> return to build)" begin
351+
state = step3_state()
352+
with_wizard_output(state, Wizard.step34) do ins, outs
353+
# Don't build anything
354+
call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit")
355+
call_response(ins, outs, "Would you like to edit this script now?", "N")
356+
357+
# Return to build environment
358+
call_response(ins, outs, "Return to build environment", "\r", newline=false)
359+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
360+
make install
361+
exit
362+
""")
363+
364+
@test succcess_path_call_response(ins, outs)
365+
end
366+
@test state.history == """
367+
cd \$WORKSPACE/srcdir
368+
exit
369+
cd \$WORKSPACE/srcdir
366370
make install
367371
exit
368-
""")
369-
370-
@test succcess_path_call_response(ins, outs)
372+
"""
373+
step3_test(state)
371374
end
372-
@test state.history == """
373-
cd \$WORKSPACE/srcdir
374-
exit
375-
cd \$WORKSPACE/srcdir
376-
cd libfoo
377-
make install
378-
exit
379-
"""
380-
step3_test(state)
381-
382-
# Step 3 failure path (no binary in destdir -> retry with a clean build environment)
383-
state = step3_state()
384-
with_wizard_output(state, Wizard.step34) do ins, outs
385-
# Don't build anything
386-
call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit")
387-
call_response(ins, outs, "Would you like to edit this script now?", "N")
388375

389-
# Clean environment
390-
call_response(ins, outs, "Return to build environment", "\e[B\r")
391-
end
392-
@test state.step == :step3
376+
@testset "Step 3 failure path (no binary in destdir -> retry with a clean build environment)" begin
377+
state = step3_state()
378+
with_wizard_output(state, Wizard.step34) do ins, outs
379+
# Don't build anything
380+
call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit")
381+
call_response(ins, outs, "Would you like to edit this script now?", "N")
393382

394-
# Step 3 with a failing script
395-
state = step3_state()
396-
with_wizard_output(state, Wizard.step34) do ins, outs
397-
# Build ok, but then indicate a failure
398-
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
399-
cd libfoo
400-
make install
401-
exit 1
402-
""")
383+
# Clean environment
384+
call_response(ins, outs, "Return to build environment", "\e[B\r")
385+
end
386+
@test state.step === :step3
387+
end
403388

404-
@test readuntil_sift(outs, "Warning:") !== nothing
389+
@testset "Step 3 with a failing script" begin
390+
state = step3_state()
391+
with_wizard_output(state, Wizard.step34) do ins, outs
392+
# Build ok, but then indicate a failure
393+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
394+
make install
395+
exit 1
396+
""")
405397

406-
@test succcess_path_call_response(ins, outs)
398+
@test readuntil_sift(outs, "Warning:") !== nothing
399+
@test succcess_path_call_response(ins, outs)
400+
end
401+
step3_test(state)
407402
end
408-
step3_test(state)
409403

410-
# Step 3 dependency download
411-
state = step3_state()
412-
state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))]
413-
with_wizard_output(state, Wizard.step34) do ins, outs
414-
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
415-
if [[ ! -f \${libdir}/libz.\${dlext} ]]; then
416-
echo "ERROR: Could not find libz.\${dlext}" >&2
404+
@testset " Step 3 - retry" begin
405+
state = step3_state()
406+
# Build ok, but then indicate a failure
407+
with_wizard_output(state, Wizard.step34) do ins, outs
408+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
409+
make install
410+
install_license LICENSE.md
417411
exit 1
418-
fi
419-
cd libfoo
420-
make install
421-
exit
422-
""")
423-
@test succcess_path_call_response(ins, outs)
412+
""")
413+
@test readuntil_sift(outs, "Warning:") !== nothing
414+
@test succcess_path_call_response(ins, outs)
415+
end
416+
with_wizard_output(state, Wizard.step3_retry) do ins, outs
417+
call_response(ins, outs, "bin/fooifier", "ad"; newline = false)
418+
call_response(ins, outs, "lib/libfoo", "libfoo")
419+
call_response(ins, outs, "bin/fooifier", "fooifier")
420+
end
421+
step3_test(state)
424422
end
425423

426-
# Step 3 - `bb add`
427-
state = step3_state()
428-
state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))]
429-
with_wizard_output(state, Wizard.step34) do ins, outs
430-
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
431-
if [[ ! -f \${libdir}/libz.\${dlext} ]]; then
432-
echo "ERROR: Could not find libz.\${dlext}" >&2
433-
exit 1
434-
fi
435-
bb add Xorg_xorgproto_jll
436-
if [[ ! -d \${includedir}/X11 ]]; then
437-
echo "ERROR: Could not find include/X11" >&2
438-
exit 1
439-
fi
440-
bb add Zlib_jll
441-
cd libfoo
442-
make install
443-
exit
444-
""")
445-
@test succcess_path_call_response(ins, outs)
424+
@testset "Step 3 dependency download" begin
425+
state = step3_state()
426+
state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))]
427+
with_wizard_output(state, Wizard.step34) do ins, outs
428+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
429+
if [[ ! -f \${libdir}/libz.\${dlext} ]]; then
430+
echo "ERROR: Could not find libz.\${dlext}" >&2
431+
exit 1
432+
fi
433+
make install
434+
exit
435+
""")
436+
@test succcess_path_call_response(ins, outs)
437+
end
438+
end
439+
440+
@testset " Step 3 - `bb add`" begin
441+
state = step3_state()
442+
state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))]
443+
with_wizard_output(state, Wizard.step34) do ins, outs
444+
call_response(ins, outs, "\${WORKSPACE}/srcdir", """
445+
if [[ ! -f \${libdir}/libz.\${dlext} ]]; then
446+
echo "ERROR: Could not find libz.\${dlext}" >&2
447+
exit 1
448+
fi
449+
bb add Xorg_xorgproto_jll
450+
if [[ ! -d \${includedir}/X11 ]]; then
451+
echo "ERROR: Could not find include/X11" >&2
452+
exit 1
453+
fi
454+
bb add Zlib_jll
455+
make install
456+
exit
457+
""")
458+
@test succcess_path_call_response(ins, outs)
459+
end
446460
end
461+
447462
end
448463

449464
function step5_state(script)
@@ -456,26 +471,55 @@ function step5_state(script)
456471
end
457472

458473
@testset "Wizard - Generalizing" begin
459-
# Check that with a failing script, step 5 rejects,
460-
# even if all artifacts are present.
461-
state = step5_state("""
462-
cd libfoo
463-
make install
464-
exit 1
465-
""")
474+
@testset "step5_internal (failure)" begin
475+
# Check that with a failing script, step 5 rejects,
476+
# even if all artifacts are present.
477+
state = step5_state("exit 1")
478+
with_wizard_output(state, state->Wizard.step5_internal(state, first(state.platforms))) do ins, outs
479+
call_response(ins, outs, "Press Enter to continue...", "\n")
480+
call_response(ins, outs, "How would you like to proceed?", "\e[B\e[B\r")
481+
end
482+
@test isempty(state.platforms)
483+
end
484+
485+
@testset "step 5 sequence (failure)" begin
486+
state = step5_state("exit 1")
487+
empty!(state.platforms)
466488

467-
with_wizard_output(state, state->Wizard.step5_internal(state, first(state.platforms))) do ins, outs
468-
call_response(ins, outs, "Press Enter to continue...", "\n")
469-
call_response(ins, outs, "How would you like to proceed?", "\e[B\e[B\r")
489+
Wizard.step5a(state)
490+
@test state.step === :step5b
491+
492+
Wizard.step5b(state)
493+
@test state.step === :step5c
494+
end
495+
496+
@testset "step 5 sequence (success)" begin
497+
state = step5_state("""
498+
cd \$WORKSPACE/srcdir
499+
make install
500+
install_license LICENSE.md
501+
exit 0
502+
""")
503+
504+
with_wizard_output(state, Wizard.step5a) do ins, outs
505+
call_response(ins, outs, "Press Enter to continue...", "\n")
506+
end
507+
@test state.step === :step5b
508+
509+
Wizard.step5b(state)
510+
@test state.step === :step5c
511+
512+
with_wizard_output(state, Wizard.step5c) do ins, outs
513+
call_response(ins, outs, "Press Enter to continue...", "\n")
514+
end
470515
end
471-
@test isempty(state.platforms)
472516
end
473517

474518
function step7_state()
475519
state = step5_state("""
476-
cd libfoo
477-
make install
478-
exit 1
520+
cd libfoos
521+
make install
522+
exit 1
479523
""")
480524
state.patches = [PatchSource("foo.patch", "this is a patch")]
481525
return state
@@ -517,6 +561,12 @@ end
517561
end
518562
end
519563

564+
@testset "Logo" begin
565+
io = PipeBuffer()
566+
Wizard.print_wizard_logo(io)
567+
@test contains(read(io, String), "https://github.com/JuliaPackaging/BinaryBuilder.jl")
568+
end
569+
520570
close(server)
521571

522572
@testset "GitHub - authentication" begin

0 commit comments

Comments
 (0)