Skip to content

Commit

Permalink
fix handling of relative paths in bind_artifact! (JuliaLang#3435)
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub authored Apr 11, 2023
1 parent 992a8c2 commit 79f5e3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ function bind_artifact!(artifacts_toml::String, name::String, hash::SHA1;

# Spit it out onto disk
let artifact_dict = artifact_dict
temp_artifacts_toml = tempname(dirname(artifacts_toml))
parent_dir = dirname(artifacts_toml)
temp_artifacts_toml = isempty(parent_dir) ? tempname(pwd()) : tempname(parent_dir)
open(temp_artifacts_toml, "w") do io
TOML.print(io, artifact_dict, sorted=true)
end
Expand Down
20 changes: 20 additions & 0 deletions test/artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,26 @@ end
meta = artifact_meta("foo_txt", artifacts_toml; platform=win32)
@test meta["download"][1]["url"] == "http://google.com/hello_world"
@test meta["download"][2]["sha256"] == "a"^64

rm(artifacts_toml)

# test relative Artifacts.toml paths (https://github.com/simeonschaub/ArtifactUtils.jl/issues/19)
cd(path) do
hash3 = create_artifact() do path
open(joinpath(path, "foo.txt"), "w") do io
print(io, "bla bla")
end
end

# Bind this artifact to something
artifacts_toml = "Artifacts.toml" # no parent dir specified
@test artifact_hash("foo_txt", artifacts_toml) == nothing
bind_artifact!(artifacts_toml, "foo_txt", hash3)

# Test that this binding worked
@test artifact_hash("foo_txt", artifacts_toml) == hash3
@test ensure_artifact_installed("foo_txt", artifacts_toml) == artifact_path(hash3)
end
end

# Let's test some known-bad Artifacts.toml files
Expand Down

0 comments on commit 79f5e3b

Please sign in to comment.