diff --git a/test/auditing.jl b/test/auditing.jl index a496ff70..1d3cfbfe 100644 --- a/test/auditing.jl +++ b/test/auditing.jl @@ -61,7 +61,7 @@ end build_path, "isa_tests", v"1.0.0", - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], # Build the test suite, install the binaries into our prefix's `bin` raw""" cd ${WORKSPACE}/srcdir/isa_tests @@ -110,7 +110,7 @@ end build_path, "isa_tests", v"1.0.0", - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], # Build the test suite, install the binaries into our prefix's `bin` raw""" cd ${WORKSPACE}/srcdir/isa_tests @@ -159,7 +159,7 @@ end build_path, "isa_tests", v"1.0.0", - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], # Build the test suite, install the binaries into our prefix's `bin` raw""" cd ${WORKSPACE}/srcdir/isa_tests @@ -217,7 +217,7 @@ end "libcxxstringabi_test", v"1.0.0", # Copy in the build_tests sources - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], script, # Build for this platform [platform], @@ -305,7 +305,7 @@ end "libfoo", v"1.0.0", # Copy in the libfoo sources - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], # Build libfoo using autotools to create a real .la file, and also # create a fake .la file (which should not be removed). Create also a # symlink libqux.la -> libfoo.la, which will be broken after libfoo.la @@ -348,7 +348,7 @@ end "libfoo", v"1.0.0", # Copy in the libfoo sources - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], libfoo_autotools_script, # Build for our platform [platform], @@ -527,7 +527,7 @@ end @testset "Auditor - gcc version" begin # These tests assume our gcc version is concrete (e.g. that Julia is linked against libgfortran) - our_libgfortran_version = libgfortran_version(platform) + our_libgfortran_version = libgfortran_version(HOST_PLATFORM) @test our_libgfortran_version != nothing mktempdir() do build_path @@ -547,7 +547,7 @@ end install_license /usr/share/licenses/libuv/LICENSE """, # Build for our platform - [platform], + [HOST_PLATFORM], # Product[hello_world], # Note: we purposefully don't require CompilerSupportLibraries, even if we @@ -558,7 +558,7 @@ end end # Extract our platform's build, run the hello_world tests: - output_meta = select_platform(build_output_meta, platform) + output_meta = select_platform(build_output_meta, HOST_PLATFORM) @test output_meta != nothing tarball_path, tarball_hash = output_meta[1:2] @@ -572,7 +572,7 @@ end unpack(tarball_path, testdir) # Attempt to run the executable, we expect it to work since it's our platform: - hello_world_path = locate(hello_world, Prefix(testdir); platform=platform) + hello_world_path = locate(hello_world, Prefix(testdir); platform=HOST_PLATFORM) with_libgfortran() do @test readchomp(`$hello_world_path`) == "Hello, World!" end @@ -580,7 +580,7 @@ end # If we audit the testdir, pretending that we're trying to build an ABI-agnostic # tarball, make sure it warns us about it. @test_logs (:warn, r"links to libgfortran!") match_mode=:any begin - @test !Auditor.audit(Prefix(testdir); platform=BinaryBuilderBase.abi_agnostic(platform), autofix=false) + @test !Auditor.audit(Prefix(testdir); platform=BinaryBuilderBase.abi_agnostic(HOST_PLATFORM), autofix=false) # Make sure audit is otherwise happy with the executable # Note by Mosè: this test was introduced before # https://github.com/JuliaPackaging/BinaryBuilder.jl/pull/1240 and relied on the @@ -588,7 +588,7 @@ end # libraries, but that was a fallacious expectation. At the moment I don't know # how to meaningfully use this test, leaving here as broken until we come up # with better ideas (just remove the test?). - @test Auditor.audit(Prefix(testdir); platform=platform, autofix=false) broken=true + @test Auditor.audit(Prefix(testdir); platform=HOST_PLATFORM, autofix=false) broken=true end # Let's pretend that we're building for a different libgfortran version: @@ -597,7 +597,7 @@ end other_libgfortran_version = libgfortran_versions[findfirst(v -> v != our_libgfortran_version.major, libgfortran_versions)] @test_logs (:warn, Regex("but we are supposedly building for libgfortran$(other_libgfortran_version)")) (:warn, r"Linked library libgfortran\.so\.(4|5)") (:warn, r"Linked library libquadmath\.so\.0") (:warn, r"Linked library libgcc_s\.so\.1") readmeta(hello_world_path) do ohs foreach(ohs) do oh - p = deepcopy(platform) + p = deepcopy(HOST_PLATFORM) p["libgfortran_version"] = "$(other_libgfortran_version).0.0" @test !Auditor.audit(Prefix(testdir); platform=p, autofix=false) end @@ -650,7 +650,7 @@ end end @testset "Auditor - rpaths" begin - @testset "$platform" for platform in (Platform("x86_64", "linux"; libc="glibc"), Platform("x86_64", "macos")) + @testset "$HOST_PLATFORM" for platform in (Platform("x86_64", "linux"; libc="glibc"), Platform("x86_64", "macos")) mktempdir() do build_path build_output_meta = nothing @test_logs (:info, "Building for $(triplet(platform))") match_mode=:any begin @@ -762,7 +762,7 @@ end chmod 640 "${libdir}/libfoo.${dlext}" """, # Build for our platform - [platform], + [HOST_PLATFORM], # Ensure our library product is built [product], # No dependencies @@ -773,8 +773,8 @@ end end # Extract our platform's build - @test haskey(build_output_meta, platform) - tarball_path, tarball_hash = build_output_meta[platform][1:2] + @test haskey(build_output_meta, HOST_PLATFORM) + tarball_path, tarball_hash = build_output_meta[HOST_PLATFORM][1:2] @test isfile(tarball_path) # Unpack it somewhere else @@ -782,7 +782,7 @@ end testdir = joinpath(build_path, "testdir") mkdir(testdir) unpack(tarball_path, testdir) - libfoo_path = joinpath(testdir, build_output_meta[platform][4][product]["path"]) + libfoo_path = joinpath(testdir, build_output_meta[HOST_PLATFORM][4][product]["path"]) # Tar.jl normalizes permissions of executable files to 0o755, instead of # recording exact original permissions: # https://github.com/JuliaIO/Tar.jl/blob/37766a22f5a6ac9f07022d83debd5db7d7a4b896/README.md#permissions @@ -994,3 +994,13 @@ end @test !valid_library_path("/usr/libc.so", macos) @test !valid_library_path("/usr/libc.so", windows) end + +@testset "platform_for_object" begin + arch_host = arch(HOST_PLATFORM) + bin = Base.julia_cmd().exec |> first + BinaryBuilder.readmeta(bin) do ohs + foreach(ohs) do oh + @test arch(Auditor.platform_for_object(oh)) == arch_host + end + end +end diff --git a/test/basic.jl b/test/basic.jl index 5f1e60eb..bd49441c 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -65,7 +65,7 @@ end exit 0 """, # Build for this platform - [platform], + [HOST_PLATFORM], # No products Product[], # No dependencies @@ -82,13 +82,13 @@ end MARKER=1 exit 1 """, - [platform], + [HOST_PLATFORM], Product[], Dependency[], ) # build_path is the nonce'd build directory - build_path = joinpath(temp_path, "build", triplet(platform)) + build_path = joinpath(temp_path, "build", triplet(HOST_PLATFORM)) build_path = joinpath(build_path, first(readdir(build_path))) # Ensure that we get a metadir, and that our history and .env files are in there! diff --git a/test/building.jl b/test/building.jl index 2cc16b18..a57e346b 100644 --- a/test/building.jl +++ b/test/building.jl @@ -10,7 +10,7 @@ # Copy files in, commit them. This is the commit we will build. repo = LibGit2.init(git_path) LibGit2.commit(repo, "Initial empty commit") - libfoo_src_dir = joinpath(build_tests_dir, "libfoo") + libfoo_src_dir = joinpath(BUILD_TESTS_DIR, "libfoo") run(`cp -r $(libfoo_src_dir)/$(readdir(libfoo_src_dir)) $(git_path)/`) for file in readdir(git_path) LibGit2.add!(repo, file) @@ -24,7 +24,7 @@ LibGit2.add!(repo, "Makefile") LibGit2.commit(repo, "Break Makefile") - for source in (DirectorySource(build_tests_dir), + for source in (DirectorySource(BUILD_TESTS_DIR), GitSource(git_path, bytes2hex(LibGit2.raw(LibGit2.GitHash(commit))))) build_output_meta = autobuild( build_path, @@ -35,7 +35,7 @@ # Use the particular build script we're interested in script, # Build for this platform - [platform], + [HOST_PLATFORM], # The products we expect to be build libfoo_products, # No dependencies @@ -46,16 +46,16 @@ verbose=true, ) - @test haskey(build_output_meta, platform) - tarball_path, tarball_hash = build_output_meta[platform][1:2] + @test haskey(build_output_meta, HOST_PLATFORM) + tarball_path, tarball_hash = build_output_meta[HOST_PLATFORM][1:2] # Ensure the build products were created @test isfile(tarball_path) # Ensure that the file contains what we expect contents = list_tarball_files(tarball_path) - @test "bin/fooifier$(platform_exeext(platform))" in contents - @test "lib/libfoo.$(platform_dlext(platform))" in contents + @test "bin/fooifier$(platform_exeext(HOST_PLATFORM))" in contents + @test "lib/libfoo.$(platform_dlext(HOST_PLATFORM))" in contents # Unpack it somewhere else @test verify(tarball_path, tarball_hash) @@ -66,8 +66,8 @@ # Ensure we can use it prefix = Prefix(testdir) - fooifier_path = joinpath(bindir(prefix), "fooifier$(platform_exeext(platform))") - libfoo_path = first(filter(f -> isfile(f), joinpath.(libdirs(prefix), "libfoo.$(platform_dlext(platform))"))) + fooifier_path = joinpath(bindir(prefix), "fooifier$(platform_exeext(HOST_PLATFORM))") + libfoo_path = first(filter(f -> isfile(f), joinpath.(libdirs(prefix), "libfoo.$(platform_dlext(HOST_PLATFORM))"))) # We know that foo(a, b) returns 2*a^2 - b result = 2*2.2^2 - 1.1 @@ -96,8 +96,8 @@ end mktempdir() do build_path name = "libfoo" build_output_meta = build_tarballs( - ["--deploy=local"], name, v"1.0.0", [DirectorySource(build_tests_dir)], - libfoo_make_script, [platform], libfoo_products, Dependency[]; + ["--deploy=local"], name, v"1.0.0", [DirectorySource(BUILD_TESTS_DIR)], + libfoo_make_script, [HOST_PLATFORM], libfoo_products, Dependency[]; skip_audit = true, ) artifacts_toml = TOML.parsefile(joinpath(BinaryBuilder.codedir(name), "Artifacts.toml")) @@ -118,12 +118,12 @@ end end end -shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(platform)) +shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(HOST_PLATFORM)) if lowercase(get(ENV, "BINARYBUILDER_FULL_SHARD_TEST", "false")) == "true" @info("Beginning full shard test... (this can take a while)") shards_to_test = supported_platforms() else - shards_to_test = [platform] + shards_to_test = [HOST_PLATFORM] end # Expand to all platforms @@ -203,7 +203,7 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test)) @test length(keys(platforms)) == length(keys(build_output_meta)) # Extract our platform's build, run the hello_world tests: - output_meta = select_platform(build_output_meta, platform) + output_meta = select_platform(build_output_meta, HOST_PLATFORM) if !isnothing(output_meta) tarball_path, tarball_hash = output_meta[1:2] @@ -376,7 +376,7 @@ end # No sources FileSource[], "true", - [HostPlatform()], + [HOST_PLATFORM], Product[], # Three dependencies; one good, two bad [ @@ -395,7 +395,7 @@ end v"1.1.1+c", GitSource[], "true", - [HostPlatform()], + [HOST_PLATFORM], Product[], Dependency[], ) @@ -405,7 +405,7 @@ end v"1.2.3-4", GitSource[], "true", - [HostPlatform()], + [HOST_PLATFORM], Product[], Dependency[], ) @@ -448,7 +448,7 @@ end build_path, "libfoo", v"1.0.0", - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], libfoo_cmake_script, [AnyPlatform()], libfoo_products, @@ -476,7 +476,7 @@ end make install """, # Build for this platform - [platform], + [HOST_PLATFORM], # The products we expect to be build [LibraryProduct("libconfuse", :libconfuse)], # No dependencies @@ -485,7 +485,7 @@ end skip_audit=true, ) end - @test haskey(build_output_meta, platform) + @test haskey(build_output_meta, HOST_PLATFORM) end @testset "Building framework" begin @@ -504,7 +504,7 @@ end build_path, "libfoo", v"1.0.0", - [DirectorySource(build_tests_dir)], + [DirectorySource(BUILD_TESTS_DIR)], # Build the test suite, install the binaries into our prefix's `bin` libfoo_cmake_script, # Build for ALL the platforms diff --git a/test/jll.jl b/test/jll.jl index e209fc5c..f4aeacf8 100644 --- a/test/jll.jl +++ b/test/jll.jl @@ -70,14 +70,14 @@ end mktempdir() do build_path name = "libfoo" version = v"1.0.0" - sources = [DirectorySource(build_tests_dir)] + sources = [DirectorySource(BUILD_TESTS_DIR)] # Build for this platform and a platform that isn't this one for sure: # FreeBSD. freebsd = Platform("x86_64", "freebsd") - platforms = [platform, freebsd] + platforms = [HOST_PLATFORM, freebsd] # We depend on Zlib_jll only on the host platform, but not on FreeBSD dependencies = [ - Dependency("Zlib_jll"; platforms=[platform]), + Dependency("Zlib_jll"; platforms=[HOST_PLATFORM]), RuntimeDependency("Preferences"; top_level=true) ] # Augment platform @@ -205,7 +205,7 @@ end end # Make sure we use Zlib_jll only in the wrapper for the host # platform and not the FreeBSD one. - platform_wrapper = joinpath(code_dir, "src", "wrappers", triplet(platform) * ".jl") + platform_wrapper = joinpath(code_dir, "src", "wrappers", triplet(HOST_PLATFORM) * ".jl") freebsd_wrapper = joinpath(code_dir, "src", "wrappers", triplet(freebsd) * ".jl") main_src = joinpath(code_dir, "src", name * "_jll.jl") @test contains(readchomp(platform_wrapper), "using Zlib_jll") diff --git a/test/runtests.jl b/test/runtests.jl index 3aa0af48..e5b12141 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,8 +6,8 @@ using Random, LibGit2, Test, ObjectFile, SHA, Downloads, TOML import Libdl # The platform we're running on -const platform = HostPlatform() -const build_tests_dir = joinpath(@__DIR__, "build_tests") +const HOST_PLATFORM = HostPlatform() +const BUILD_TESTS_DIR = joinpath(@__DIR__, "build_tests") # Helper function to run fortran code with the path to libgfortran/libquadmath # embedded in the appropriate environment variables (JLL packages we love you so) diff --git a/test/wizard.jl b/test/wizard.jl index f03b9808..b930237e 100644 --- a/test/wizard.jl +++ b/test/wizard.jl @@ -4,6 +4,12 @@ import Pkg: PackageSpec import BinaryBuilder.BinaryBuilderBase: available_gcc_builds, available_llvm_builds, getversion +# cursor movement in the terminal +const UP = "\e[A" +const DOWN = "\e[B" +const RGHT = "\e[C" +const LEFT = "\e[D" + const debug = Ref(false) function with_wizard_output(f::Function, state, step_func::Function) @@ -17,8 +23,6 @@ function with_wizard_output(f::Function, state, step_func::Function) reader_task = @async begin while isopen(pty.master) z = String(readavailable(pty.master)) - - # Un-comment this to figure out what on earth is going wrong debug[] && print(z) write(out_buff, z) end @@ -31,16 +35,13 @@ function with_wizard_output(f::Function, state, step_func::Function) catch e bt = catch_backtrace() Base.display_error(stderr, e, bt) - - # If this fails, panic - Test.@test false + Test.@test false # If this fails, panic end end f(pty.master, out_buff) - # Wait for the wizard to finish - wait(wizard_task) + wait(wizard_task) # Wait for the wizard to finish # Once that's done, kill the reader task close(pty.master) @@ -50,7 +51,7 @@ end # Test the download stage r = HTTP.Router() io = IOBuffer() -Tar.create(joinpath(build_tests_dir, "libfoo"), pipeline(`gzip -9`, io)) +Tar.create(joinpath(BUILD_TESTS_DIR, "libfoo"), pipeline(`gzip -9`, io)) libfoo_tarball_data = take!(io) libfoo_tarball_hash = bytes2hex(sha256(libfoo_tarball_data)) function serve_tgz(req) @@ -172,6 +173,25 @@ end end @test state.name == "cuba" @test state.version == v"1.2.3" + + state = Wizard.WizardState() + with_wizard_output(state, Wizard.step1) do ins, outs + call_response(ins, outs, "Make a platform selection", "\r") + end + @test state.platforms == supported_platforms() + + state = Wizard.WizardState() + with_wizard_output(state, Wizard.step1) do ins, outs + call_response(ins, outs, "Make a platform selection", "$DOWN\r") + call_response(ins, outs, "Select operating systems", "$DOWN\rd"; newline = false) + end + + state = Wizard.WizardState() + with_wizard_output(state, Wizard.step1) do ins, outs + call_response(ins, outs, "Make a platform selection", "$DOWN$DOWN\r") + call_response(ins, outs, "Select platforms", "$DOWN\rd"; newline = false) + end + @test length(state.platforms) == 1 end # Set the state up @@ -200,7 +220,7 @@ end call_response(ins, outs, "Do you want to customize the set of compilers?", "Y") call_response(ins, outs, "Select compilers for the project", "ad") call_response(ins, outs, "Select the preferred GCC version", "\r") - call_response(ins, outs, "Select the preferred LLVM version", "\e[B\e[B\e[B\r") + call_response(ins, outs, "Select the preferred LLVM version", "$DOWN$DOWN$DOWN\r") end # Check that the state is modified appropriately @test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"] @@ -306,16 +326,12 @@ end end end - - # Dump the tarball to disk so that we can use it directly in the future tempspace = tempname() mkdir(tempspace) libfoo_tarball_path = joinpath(tempspace, "source.tar.gz") open(f -> write(f, libfoo_tarball_data), libfoo_tarball_path, "w") - - function step3_state() state = Wizard.WizardState() state.step = :step34 @@ -339,123 +355,142 @@ function step3_test(state) libfoo_idx = findfirst(state.files .== "lib/libfoo.so") fooifier_idx = findfirst(state.files .== "bin/fooifier") - @test state.file_kinds[libfoo_idx] == :library - @test state.file_kinds[fooifier_idx] == :executable - @test state.file_varnames[libfoo_idx] == :libfoo - @test state.file_varnames[fooifier_idx] == :fooifier + @test state.file_kinds[libfoo_idx] === :library + @test state.file_kinds[fooifier_idx] === :executable + @test state.file_varnames[libfoo_idx] === :libfoo + @test state.file_varnames[fooifier_idx] === :fooifier end @testset "Wizard - Building" begin - # Test step3 success path - state = step3_state() - with_wizard_output(state, Wizard.step34) do ins, outs - call_response(ins, outs, "\${WORKSPACE}/srcdir", """ - cd libfoo + @testset "Test step3 success path" begin + state = step3_state() + with_wizard_output(state, Wizard.step34) do ins, outs + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + make install + exit + """) + @test succcess_path_call_response(ins, outs) + end + @test state.history == """ + cd \$WORKSPACE/srcdir make install exit - """) - @test succcess_path_call_response(ins, outs) + """ + step3_test(state) end - @test state.history == """ - cd \$WORKSPACE/srcdir - cd libfoo - make install - exit - """ - step3_test(state) - # Step 3 failure path (no binary in destdir -> return to build) - state = step3_state() - with_wizard_output(state, Wizard.step34) do ins, outs - # Don't build anything - call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit") - call_response(ins, outs, "Would you like to edit this script now?", "N") - - # Return to build environment - call_response(ins, outs, "Return to build environment", "\r", newline=false) - call_response(ins, outs, "\${WORKSPACE}/srcdir", """ - cd libfoo + @testset "Step 3 failure path (no binary in destdir -> return to build)" begin + state = step3_state() + with_wizard_output(state, Wizard.step34) do ins, outs + # Don't build anything + call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit") + call_response(ins, outs, "Would you like to edit this script now?", "N") + + # Return to build environment + call_response(ins, outs, "Return to build environment", "\r", newline=false) + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + make install + exit + """) + + @test succcess_path_call_response(ins, outs) + end + @test state.history == """ + cd \$WORKSPACE/srcdir + exit + cd \$WORKSPACE/srcdir make install exit - """) - - @test succcess_path_call_response(ins, outs) + """ + step3_test(state) end - @test state.history == """ - cd \$WORKSPACE/srcdir - exit - cd \$WORKSPACE/srcdir - cd libfoo - make install - exit - """ - step3_test(state) - # Step 3 failure path (no binary in destdir -> retry with a clean build environment) - state = step3_state() - with_wizard_output(state, Wizard.step34) do ins, outs - # Don't build anything - call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit") - call_response(ins, outs, "Would you like to edit this script now?", "N") + @testset "Step 3 failure path (no binary in destdir -> retry with a clean build environment)" begin + state = step3_state() + with_wizard_output(state, Wizard.step34) do ins, outs + # Don't build anything + call_response(ins, outs, "\${WORKSPACE}/srcdir", "exit") + call_response(ins, outs, "Would you like to edit this script now?", "N") - # Clean environment - call_response(ins, outs, "Return to build environment", "\e[B\r") + # Clean environment + call_response(ins, outs, "Return to build environment", "$DOWN\r") + end + @test state.step === :step3 end - @test state.step == :step3 - # Step 3 with a failing script - state = step3_state() - with_wizard_output(state, Wizard.step34) do ins, outs - # Build ok, but then indicate a failure - call_response(ins, outs, "\${WORKSPACE}/srcdir", """ - cd libfoo - make install - exit 1 - """) - - @test readuntil_sift(outs, "Warning:") !== nothing + @testset "Step 3 with a failing script" begin + state = step3_state() + with_wizard_output(state, Wizard.step34) do ins, outs + # Build ok, but then indicate a failure + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + make install + exit 1 + """) - @test succcess_path_call_response(ins, outs) + @test readuntil_sift(outs, "Warning:") !== nothing + @test succcess_path_call_response(ins, outs) + end + step3_test(state) end - step3_test(state) - # Step 3 dependency download - state = step3_state() - state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))] - with_wizard_output(state, Wizard.step34) do ins, outs - call_response(ins, outs, "\${WORKSPACE}/srcdir", """ - if [[ ! -f \${libdir}/libz.\${dlext} ]]; then - echo "ERROR: Could not find libz.\${dlext}" >&2 + @testset " Step 3 - retry" begin + state = step3_state() + # Build ok, but then indicate a failure + with_wizard_output(state, Wizard.step34) do ins, outs + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + make install + install_license LICENSE.md exit 1 - fi - cd libfoo - make install - exit - """) - @test succcess_path_call_response(ins, outs) + """) + @test readuntil_sift(outs, "Warning:") !== nothing + @test succcess_path_call_response(ins, outs) + end + with_wizard_output(state, Wizard.step3_retry) do ins, outs + call_response(ins, outs, "bin/fooifier", "ad"; newline = false) + call_response(ins, outs, "lib/libfoo", "libfoo") + call_response(ins, outs, "bin/fooifier", "fooifier") + end + step3_test(state) end - # Step 3 - `bb add` - state = step3_state() - state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))] - with_wizard_output(state, Wizard.step34) do ins, outs - call_response(ins, outs, "\${WORKSPACE}/srcdir", """ - if [[ ! -f \${libdir}/libz.\${dlext} ]]; then - echo "ERROR: Could not find libz.\${dlext}" >&2 - exit 1 - fi - bb add Xorg_xorgproto_jll - if [[ ! -d \${includedir}/X11 ]]; then - echo "ERROR: Could not find include/X11" >&2 - exit 1 - fi - bb add Zlib_jll - cd libfoo - make install - exit - """) - @test succcess_path_call_response(ins, outs) + @testset "Step 3 dependency download" begin + state = step3_state() + state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))] + with_wizard_output(state, Wizard.step34) do ins, outs + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + if [[ ! -f \${libdir}/libz.\${dlext} ]]; then + echo "ERROR: Could not find libz.\${dlext}" >&2 + exit 1 + fi + make install + exit + """) + @test succcess_path_call_response(ins, outs) + end end + + @testset " Step 3 - `bb add`" begin + state = step3_state() + state.dependencies = [Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a"))] + with_wizard_output(state, Wizard.step34) do ins, outs + call_response(ins, outs, "\${WORKSPACE}/srcdir", """ + if [[ ! -f \${libdir}/libz.\${dlext} ]]; then + echo "ERROR: Could not find libz.\${dlext}" >&2 + exit 1 + fi + bb add Xorg_xorgproto_jll + if [[ ! -d \${includedir}/X11 ]]; then + echo "ERROR: Could not find include/X11" >&2 + exit 1 + fi + bb add Zlib_jll + make install + exit + """) + @test succcess_path_call_response(ins, outs) + end + end + end function step5_state(script) @@ -468,26 +503,66 @@ function step5_state(script) end @testset "Wizard - Generalizing" begin - # Check that with a failing script, step 5 rejects, - # even if all artifacts are present. - state = step5_state(""" - cd libfoo - make install - exit 1 - """) + @testset "step5_internal (failure)" begin + # Check that with a failing script, step 5 rejects, + # even if all artifacts are present. + state = step5_state("exit 1") + with_wizard_output(state, state->Wizard.step5_internal(state, first(state.platforms))) do ins, outs + call_response(ins, outs, "Press Enter to continue...", "\n") + call_response(ins, outs, "How would you like to proceed?", "$DOWN$DOWN\r") + end + @test isempty(state.platforms) + end + + @testset "step 5 sequence (failure)" begin + state = step5_state("exit 1") + empty!(state.platforms) + + Wizard.step5a(state) + @test state.step === :step5b - with_wizard_output(state, state->Wizard.step5_internal(state, first(state.platforms))) do ins, outs - call_response(ins, outs, "Press Enter to continue...", "\n") - call_response(ins, outs, "How would you like to proceed?", "\e[B\e[B\r") + Wizard.step5b(state) + @test state.step === :step5c + + with_wizard_output(state, Wizard.step5c) do ins, outs + call_response(ins, outs, "Press Enter to continue...", "\n") + end + @test state.step === :step5c + end + + @testset "step 5/6 sequence (success)" begin + state = step5_state(""" + cd \$WORKSPACE/srcdir + make install + install_license LICENSE.md + exit 0 + """) + + with_wizard_output(state, Wizard.step5a) do ins, outs + call_response(ins, outs, "Press Enter to continue...", "\n") + end + @test state.step === :step5b + + Wizard.step5b(state) + @test state.step === :step5c + + with_wizard_output(state, Wizard.step5c) do ins, outs + call_response(ins, outs, "Press Enter to continue...", "\n") + end + push!(state.failed_platforms, first(filter(x -> x != HOST_PLATFORM, supported_platforms()))) + @show state.platforms state.validated_platforms state.failed_platforms + + with_wizard_output(state, Wizard.step6) do ins, outs + call_response(ins, outs, "How would you like to proceed? (CTRL-C to exit)", "\r") + end + @test state.step === :step7 end - @test isempty(state.platforms) end function step7_state() state = step5_state(""" - cd libfoo - make install - exit 1 + make install + exit 1 """) state.patches = [PatchSource("foo.patch", "this is a patch")] return state @@ -498,7 +573,7 @@ end # First, test local deployment mktempdir() do out_dir with_wizard_output(state, state->Wizard._deploy(state)) do ins, outs - call_response(ins, outs, "How should we deploy this build recipe?", "\e[B\r") + call_response(ins, outs, "How should we deploy this build recipe?", "$DOWN\r") call_response(ins, outs, "Enter directory to write build_tarballs.jl to:", "$(out_dir)\r") end @test isfile(joinpath(out_dir, "build_tarballs.jl")) @@ -508,7 +583,7 @@ end # Next, test writing out to stdout state = step7_state() with_wizard_output(state, state->Wizard._deploy(state)) do ins, outs - call_response(ins, outs, "How should we deploy this build recipe?", "\e[B\e[B\r") + call_response(ins, outs, "How should we deploy this build recipe?", "$DOWN$DOWN\r") @test readuntil_sift(outs, "Your generated build_tarballs.jl:") !== nothing @test readuntil_sift(outs, "name = \"libfoo\"") !== nothing @test readuntil_sift(outs, "make install") !== nothing @@ -529,6 +604,12 @@ end end end +@testset "Logo" begin + io = PipeBuffer() + Wizard.print_wizard_logo(io) + @test contains(read(io, String), "https://github.com/JuliaPackaging/BinaryBuilder.jl") +end + close(server) @testset "GitHub - authentication" begin