Skip to content

Commit

Permalink
avoid test setting ENV to "nothing"
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 22, 2024
1 parent 736ac32 commit 5d98110
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test/artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,27 @@ end
@test_logs (:error, r"malformed, must be array or dict!") artifact_meta("broken_artifact", joinpath(badifact_dir, "not_a_table.toml"))

# Next, test incorrect download errors
for ignore_hash in (false, true); withenv("JULIA_PKG_IGNORE_HASHES" => ignore_hash ? "1" : nothing) do; mktempdir() do dir
with_artifacts_directory(dir) do
@test artifact_meta("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml")) != nothing
if !ignore_hash
@test_throws ErrorException ensure_artifact_installed("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml"))
else
@test_logs (:error, r"Tree Hash Mismatch!") match_mode=:any begin
path = ensure_artifact_installed("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml"))
@test endswith(path, "0000000000000000000000000000000000000000")
@test isdir(path)
for ignore_hash in (false, true);
ignore_hash && ENV["JULIA_PKG_IGNORE_HASHES"] = "1"
try
mktempdir() do dir
with_artifacts_directory(dir) do
@test artifact_meta("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml")) != nothing
if !ignore_hash
@test_throws ErrorException ensure_artifact_installed("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml"))
else
@test_logs (:error, r"Tree Hash Mismatch!") match_mode=:any begin
path = ensure_artifact_installed("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml"))
@test endswith(path, "0000000000000000000000000000000000000000")
@test isdir(path)
end
end
end
end
end end end
finally
ignore_hash && delete!(ENV, "JULIA_PKG_IGNORE_HASHES")
end
end

mktempdir() do dir
with_artifacts_directory(dir) do
Expand Down

0 comments on commit 5d98110

Please sign in to comment.