Skip to content

Commit

Permalink
Fix hanging tests
Browse files Browse the repository at this point in the history
Yggdrasil pull request JuliaPackaging/Yggdrasil#4472
deleted the file `L/LibCURL/build_tarballs.jl`, which made the test checking
that the file exists fail.  Arguably, we should make the check more robust, but
it'd be considerably more work for relatively little gain (vast majority of
packages do follow the predictable naming scheme).
  • Loading branch information
giordano committed Feb 28, 2022
1 parent ad805cb commit 1ae06ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
25 changes: 15 additions & 10 deletions src/wizard/yggdrasil.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Only update yggdrasil once
const yggdrasil_updated = Ref(false)
yggdrasil_updated = false
function get_yggdrasil()
# TODO: Eventually, we want to use a Pkg cache to store Yggdrasil,
# but since that doens't exist yet, we'll stick it into `deps`:
yggdrasil_dir = BinaryBuilderBase.cached_git_clone("https://github.com/JuliaPackaging/Yggdrasil.git"; verbose=true)

if !yggdrasil_updated[]
@info("Updating bare Yggdrasil clone in deps/Yggdrasil...")
repo = LibGit2.GitRepo(yggdrasil_dir)
LibGit2.fetch(repo)
origin_master_oid = LibGit2.GitHash(LibGit2.lookup_branch(repo, "origin/master", true))
LibGit2.reset!(repo, origin_master_oid, LibGit2.Consts.RESET_SOFT)
yggdrasil_dir = abspath(joinpath(@__DIR__, "..", "..", "deps", "Yggdrasil"))

if !isdir(yggdrasil_dir)
@info( "Cloning bare Yggdrasil into deps/Yggdrasil...")
LibGit2.clone("https://github.com/JuliaPackaging/Yggdrasil.git", yggdrasil_dir; isbare=true)
else
if !yggdrasil_updated
@info("Updating bare Yggdrasil clone in deps/Yggdrasil...")
repo = LibGit2.GitRepo(yggdrasil_dir)
LibGit2.fetch(repo)
origin_master_oid = LibGit2.GitHash(LibGit2.lookup_branch(repo, "origin/master", true))
LibGit2.reset!(repo, origin_master_oid, LibGit2.Consts.RESET_SOFT)
end
end
yggdrasil_updated[] = true
global yggdrasil_updated = true
return yggdrasil_dir
end

Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ install_license ${WORKSPACE}/srcdir/libfoo/LICENSE.md
"""

# Run all our tests
# include("basic.jl")
# include("building.jl")
# include("auditing.jl")
# include("jll.jl")
include("basic.jl")
include("building.jl")
include("auditing.jl")
include("jll.jl")
include("wizard.jl")
include("declarative.jl")
27 changes: 3 additions & 24 deletions test/wizard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,21 @@ function with_wizard_output(f::Function, state, step_func::Function)
end

# Test the download stage
@info "Start setting up the server..."
r = HTTP.Router()
io = IOBuffer()
@info "creating tarball..."
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)
HTTP.Response(200, libfoo_tarball_data)
end
@info "Registering artifact..."
HTTP.@register(r, "GET", "/*/source.tar.gz", serve_tgz)
port = -1
@info "Creating server..."
server = Sockets.TCPServer()
# Try to connect to different ports, in case one is busy. Important in case we
# have multiple parallel builds.
available_ports = 14444:14544
for i in available_ports
@info "Trying port $(i)"
try
# Update the global server to shut it down when we are done with it.
global server = Sockets.listen(Sockets.InetAddr(Sockets.localhost, i))
Expand All @@ -84,10 +79,8 @@ for i in available_ports
# All looks good, update the global `port` and start the server
global port = i
@async HTTP.serve(r, Sockets.localhost, port; server=server, verbose=false)
@info "port $(port) is good, move on"
break
end
@info "$(@__FILE__):$(@__LINE__)"

function readuntil_sift(io::IO, needle)
# N.B.: This is a terrible way to do this and works around the fact that our `IOBuffer`
Expand Down Expand Up @@ -124,46 +117,32 @@ function call_response(ins, outs, question, answer; newline=true)
end

@testset "Wizard - Obtain source" begin
@info "$(@__FILE__):$(@__LINE__)"
state = Wizard.WizardState()
# Use a non existing name
@info "$(@__FILE__):$(@__LINE__)"
with_wizard_output(state, Wizard.get_name_and_version) do ins, outs
# Append "_jll" to the name and make sure this is automatically removed
call_response(ins, outs, "Enter a name for this project", "libfoobarqux_jll")
call_response(ins, outs, "Enter a version number", "1.2.3")
end
@info "$(@__FILE__):$(@__LINE__)"
@test state.name == "libfoobarqux"
@test state.version == v"1.2.3"
state.name = nothing
# Use an existing name, choose a new one afterwards
@info "$(@__FILE__):$(@__LINE__)"
with_wizard_output(state, Wizard.get_name_and_version) do ins, outs
@info "$(@__FILE__):$(@__LINE__)"
call_response(ins, outs, "Enter a name for this project", "libcurl")
@info "$(@__FILE__):$(@__LINE__)"
call_response(ins, outs, "Enter a name for this project", "cuba")
call_response(ins, outs, "Choose a new project name", "y")
@info "$(@__FILE__):$(@__LINE__)"
call_response(ins, outs, "Enter a name for this project", "libfoobarqux")
@info "$(@__FILE__):$(@__LINE__)"
end
@info "$(@__FILE__):$(@__LINE__)"
@test state.name == "libfoobarqux"
@test state.version == v"1.2.3"
@info "$(@__FILE__):$(@__LINE__)"
state.name = nothing
@info "$(@__FILE__):$(@__LINE__)"
# Use an existing name, confirm the choice
@info "$(@__FILE__):$(@__LINE__)"
with_wizard_output(state, Wizard.get_name_and_version) do ins, outs
call_response(ins, outs, "Enter a name for this project", "libcurl")
call_response(ins, outs, "Enter a name for this project", "cuba")
call_response(ins, outs, "Choose a new project name", "N")
end
@info "$(@__FILE__):$(@__LINE__)"
@test state.name == "libcurl"
@test state.name == "cuba"
@test state.version == v"1.2.3"
@info "$(@__FILE__):$(@__LINE__)"
end

# Set the state up
Expand Down

0 comments on commit 1ae06ff

Please sign in to comment.