Skip to content

Commit 1daf145

Browse files
vtjnashJeffBezanson
authored andcommitted
SHA,tests: cleanup tempdir (#30655)
1 parent 8e571bb commit 1daf145

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

stdlib/SHA/test/runtests.jl

+14-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const VERBOSE = false
99
lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
1010
so_many_as_array = repeat([0x61], 1000000)
1111
so_many_as_tuple = ntuple((i) -> 0x61, 1000000)
12-
file = ".sha" # Subject to change
12+
tempdir = mktempdir()
13+
file = joinpath(tempdir, ".sha")
1314
fIO = open(file, "w")
1415
write(fIO, '\0')
1516
close(fIO)
@@ -274,16 +275,24 @@ end
274275
# test error if eltype of input is not UInt8
275276
for f in sha_funcs
276277
global nerrors
278+
data = UInt32[0x23467, 0x324775]
277279
try
278-
f(UInt32[0x23467, 0x324775])
279-
warn("Non-UInt8 Arrays should fail")
280-
nerrors += 1
281-
catch
280+
f(data)
281+
catch ex
282+
if ex isa MethodError &&
283+
ex.f === f &&
284+
ex.args === (data,)
285+
continue
286+
end
287+
rethrow()
282288
end
289+
warn("Non-UInt8 Arrays should fail")
290+
nerrors += 1
283291
end
284292

285293
# Clean up the I/O mess
286294
rm(file)
295+
rm(tempdir)
287296

288297
if nerrors == 0
289298
VERBOSE && println("ALL OK")

0 commit comments

Comments
 (0)