Skip to content

Commit

Permalink
fix tests for TEMP_CLEANUP, which might be a Lockable (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Jan 30, 2024
1 parent 4a5f003 commit 997089b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ArgTools"
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
authors = ["Stefan Karpinski <[email protected]> and contributors"]
version = "1.1.1"
version = "1.1.2"

[compat]
julia = "1.3"
Expand Down
39 changes: 30 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,36 @@ import Base.Filesystem: TEMP_CLEANUP
@test_throws ErrorException send_data(ErrIO(), dst)
@test !isfile(dst)
end
@testset "arg_write(nothing)" begin
SAVE_TEMP_CLEANUP = copy(TEMP_CLEANUP)
empty!(TEMP_CLEANUP)
try
@test_throws ErrorException send_data(ErrIO())
@test length(TEMP_CLEANUP) == 1
@test !ispath(first(keys(TEMP_CLEANUP)))
finally
merge!(TEMP_CLEANUP, SAVE_TEMP_CLEANUP)
# post-https://github.com/JuliaLang/julia/pull/52898 we need to acquire
# the lock and unpack `TEMP_CLEANUP` to use it.
if isdefined(Base, :Lockable) && TEMP_CLEANUP isa Base.Lockable
@testset "arg_write(nothing)" begin
local SAVE_TEMP_CLEANUP
@lock TEMP_CLEANUP begin
SAVE_TEMP_CLEANUP = copy(TEMP_CLEANUP[])
empty!(TEMP_CLEANUP[])
end
try
@test_throws ErrorException send_data(ErrIO())
@lock TEMP_CLEANUP begin
@test length(TEMP_CLEANUP[]) == 1
@test !ispath(first(keys(TEMP_CLEANUP[])))
end
finally
@lock TEMP_CLEANUP merge!(TEMP_CLEANUP[], SAVE_TEMP_CLEANUP)
end
end
else
@testset "arg_write(nothing)" begin
SAVE_TEMP_CLEANUP = copy(TEMP_CLEANUP)
empty!(TEMP_CLEANUP)
try
@test_throws ErrorException send_data(ErrIO())
@test length(TEMP_CLEANUP) == 1
@test !ispath(first(keys(TEMP_CLEANUP)))
finally
merge!(TEMP_CLEANUP, SAVE_TEMP_CLEANUP)
end
end
end
end
Expand Down

0 comments on commit 997089b

Please sign in to comment.