Skip to content

Commit b1063f8

Browse files
authored
Add tests for with_logfile (#361)
1 parent 94b0852 commit b1063f8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/runners.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,32 @@ using Pkg
3333
@test !prefer_clang(Platform("x86_64", "linux"; sanitize="thread"))
3434
end
3535

36+
@testset "with_logfile" begin
37+
mktempdir() do dir
38+
logfile = joinpath(dir, "dir", "logfile.txt")
39+
with_logfile(logfile) do io
40+
print(io, logfile)
41+
end
42+
@test readchomp(logfile) == logfile
43+
# Test writing on an existing file
44+
with_logfile(logfile) do io
45+
print(io, logfile * logfile)
46+
end
47+
@test readchomp(logfile) == logfile * logfile
48+
49+
# Test using a Prefix as argument
50+
prefix = Prefix(dir)
51+
subdir = "my_package"
52+
ldir = logdir(prefix; subdir)
53+
name = "logfile.txt"
54+
logfile = joinpath(ldir, name)
55+
with_logfile(prefix, name; subdir) do io
56+
print(io, logfile)
57+
end
58+
@test readchomp(logfile) == logfile
59+
end
60+
end
61+
3662
# Are we using docker? If so, test that the docker runner works...
3763
@testset "Runner utilities" begin
3864
# Test that is_ecryptfs works for something we're certain isn't encrypted

0 commit comments

Comments
 (0)