Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Add test for FileProduct mappings (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat authored Aug 13, 2018
1 parent c5c1537 commit 7740bb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Products.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,12 @@ here, but included for uniformity.
function locate(fp::FileProduct; platform::Platform = platform_key(),
verbose::Bool = false, isolate::Bool = false)
# Limited variable expansion capabilities
mappings = Dict(
"\$target" => triplet(platform),
"\${target}" => triplet(platform),
)
mappings = Dict()

for (var, val) in [("target", triplet(platform)), ("nbits", wordsize(platform))]
mappings["\$$(var)"] = string(val)
mappings["\${$(var)}"] = string(val)
end

expanded = fp.path
for (old, new) in mappings
Expand All @@ -348,10 +350,13 @@ function locate(fp::FileProduct; platform::Platform = platform_key(),

if isfile(expanded)
if verbose
@info("FileProduct $(expanded) does not exist")
@info("FileProduct $(fp.path) found at $(realpath(expanded))")
end
return expanded
end
if verbose
@info("FileProduct $(fp.path) not found")
end
return nothing
end

Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,18 @@ end
f = FileProduct(joinpath(prefix, "etc", "foo.conf"), :foo_conf)
@test repr(f) == "FileProduct($(repr(joinpath(prefix, "etc", "foo.conf"))), :foo_conf)"
end

# Test that FileProduct's can have `${target}` within their paths:
temp_prefix() do prefix
multilib_dir = joinpath(prefix, "foo", triplet(platform_key()))
mkpath(multilib_dir)
touch(joinpath(multilib_dir, "bar"))

for path in ("foo/\$target/bar", "foo/\${target}/bar")
f = FileProduct(prefix, path, :bar)
@test satisfied(f; verbose=true, platform=platform_key())
end
end
end

@testset "Packaging" begin
Expand Down

0 comments on commit 7740bb1

Please sign in to comment.