Skip to content

Commit a6094a2

Browse files
committed
Add more tests for run_interactive
1 parent fac1994 commit a6094a2

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <[email protected]>"]
4-
version = "1.2.1"
4+
version = "1.2.2"
55

66
[deps]
77
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"

test/runners.jl

+17-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ end
7373
end
7474
end
7575

76+
@testset "run_interactive" begin
77+
platform = default_host_platform
78+
io = IOBuffer()
79+
@test run_interactive(preferred_runner()(mktempdir(); platform), `/bin/bash -c "echo hello world"`, stdout=io)
80+
s = String(take!(io))
81+
@test s == "hello world\n"
82+
# Make sure that `run_interactive` consistently throws an error when the process fails,
83+
# whatever is the type of `stdout`, or it consistently ignores failures if so requested.
84+
# Ref: https://github.com/JuliaPackaging/BinaryBuilderBase.jl/pull/201#issuecomment-1003192121
85+
cmd = `/bin/bash -c "false"`
86+
@test_throws ProcessFailedException run_interactive(preferred_runner()(mktempdir(); platform), cmd)
87+
@test_throws ProcessFailedException run_interactive(preferred_runner()(mktempdir(); platform), cmd; stdout=IOBuffer())
88+
cmd = Cmd(`/bin/bash -c "false"`; ignorestatus=true)
89+
@test !run_interactive(preferred_runner()(mktempdir(); platform), cmd)
90+
@test !run_interactive(preferred_runner()(mktempdir(); platform), cmd; stdout=IOBuffer())
91+
end
92+
7693
if lowercase(get(ENV, "BINARYBUILDER_FULL_SHARD_TEST", "false")) == "true"
7794
@info("Beginning full shard test... (this can take a while)")
7895
platforms = supported_platforms()
@@ -322,10 +339,3 @@ end
322339
end
323340
end
324341
end
325-
326-
@testset "outptut runner" begin
327-
io = IOBuffer()
328-
run_interactive(BinaryBuilderBase.preferred_runner()(mktempdir(); platform=Platform("x86_64", "linux"; libc="musl")), `/bin/bash -c "echo hello world"`, stdout=io)
329-
s = String(take!(io))
330-
@test s == "hello world\n"
331-
end

0 commit comments

Comments
 (0)