Skip to content

Commit 91e6bd3

Browse files
committed
Write patches out to disk when deploying locally in Wizard
1 parent 55c891c commit 91e6bd3

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/wizard/deploy.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function print_build_tarballs(io::IO, state::WizardState)
55
url_string = repr(x[1])
66
if endswith(x[1], ".git")
77
"GitSource($(url_string), $(repr(x[2].hash)))"
8-
elseif any(endswith(x[1], ext) for ext in archive_extensions)
8+
elseif any(endswith(x[1], ext) for ext in BinaryBuilderBase.archive_extensions)
99
"ArchiveSource($(url_string), $(repr(x[2].hash)))"
1010
else
1111
"FileSource($(url_string), $(repr(x[2].hash)))"
@@ -236,14 +236,21 @@ function _deploy(state::WizardState)
236236
elseif deploy_select == 2
237237
directory = nonempty_line_prompt(
238238
"filename",
239-
"Enter directory where to write build_tarballs.jl to:";
239+
"Enter directory to write build_tarballs.jl to:";
240240
ins=state.ins,
241241
outs=state.outs,
242242
)
243243
mkpath(directory)
244244
open(joinpath(directory, "build_tarballs.jl"), "w") do io
245245
print_build_tarballs(io, state)
246246
end
247+
if !isempty(state.patches)
248+
mkpath(joinpath(directory, "bundled", "patches"))
249+
for patch in state.patches
250+
patch_path = joinpath(directory, "bundled", "patches", patch.name)
251+
open(f->write(f, patch.patch), patch_path, "w")
252+
end
253+
end
247254
else
248255
println(state.outs, "Your generated build_tarballs.jl:")
249256
println(state.outs, "\n```")

test/wizard.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,41 @@ end
379379
@test isempty(state.platforms)
380380
end
381381

382+
function step7_state()
383+
state = step5_state("""
384+
cd libfoo
385+
make install
386+
exit 1
387+
""")
388+
state.patches = [PatchSource("foo.patch", "this is a patch")]
389+
return state
390+
end
391+
392+
@testset "Wizard - Deployment" begin
393+
state = step7_state()
394+
# First, test local deployment
395+
mktempdir() do out_dir
396+
with_wizard_output(state, state->Wizard._deploy(state)) do ins, outs
397+
call_response(ins, outs, "How should we deploy this build recipe?", "\e[B\r")
398+
call_response(ins, outs, "Enter directory to write build_tarballs.jl to:", "$(out_dir)\r")
399+
end
400+
@test isfile(joinpath(out_dir, "build_tarballs.jl"))
401+
@test isfile(joinpath(out_dir, "bundled", "patches", "foo.patch"))
402+
end
403+
404+
# Next, test writing out to stdout
405+
state = step7_state()
406+
with_wizard_output(state, state->Wizard._deploy(state)) do ins, outs
407+
call_response(ins, outs, "How should we deploy this build recipe?", "\e[B\e[B\r")
408+
@test readuntil_sift(outs, "Your generated build_tarballs.jl:")
409+
@test readuntil_sift(outs, "name = \"libfoo\"")
410+
@test readuntil_sift(outs, "make install")
411+
@test readuntil_sift(outs, "LibraryProduct(\"libfoo\", :libfoo)")
412+
@test readuntil_sift(outs, "ExecutableProduct(\"fooifier\", :fooifier)")
413+
@test readuntil_sift(outs, "dependencies = Dependency[")
414+
end
415+
end
416+
382417
@testset "GitHub - authentication" begin
383418
withenv("GITHUB_TOKEN" => "") do
384419
@test Wizard.github_auth(allow_anonymous=true) isa GitHub.AnonymousAuth

0 commit comments

Comments
 (0)