diff options
author | regnat <rg@regnat.ovh> | 2021-07-08 13:29:58 +0200 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2021-07-08 13:53:52 +0200 |
commit | 7e5c79a2d210e7b986803d5fe5c7ebb504b3e74e (patch) | |
tree | ab25d0c87847e4f8b835801e35de6304f4411290 /tests | |
parent | 2c8240677edb94f17cc0bcd681e442c46b987013 (diff) |
Forbid the `name` attribute for fetchTree
We need to support it for the “old” fetch* functions for backwards
compatibility, but we don’t need it for fetchTree (as it’s a new
function).
Given that changing the `name` messes-up the content hashing, we can
just forbid passing a custom `name` argument to it
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tarball.sh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/tarball.sh b/tests/tarball.sh index 279ef5672..1301922a5 100644 --- a/tests/tarball.sh +++ b/tests/tarball.sh @@ -30,7 +30,6 @@ test_tarball() { nix-build -o $TEST_ROOT/result -E "import (fetchTree file://$tarball)" nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; })" nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; })" - nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; name = \"foo\"; })" nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"sha256-xdKv2pq/IiwLSnBBJXW8hNowI4MrdZfW+SYqDQs7Tzc=\"; })" 2>&1 | grep 'NAR hash mismatch in input' nix-instantiate --strict --eval -E "!((import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; })) ? submodules)" >&2 @@ -41,6 +40,11 @@ test_tarball() { (! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file://no-such-tarball$ext) nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file://no-such-tarball$ext -I fnord=. + + # Ensure that the `name` attribute isn’t accepted as that would mess + # with the content-addressing + (! nix-instantiate --eval -E "fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; name = \"foo\"; }") + } test_tarball '' cat |