2024-05-28 16:43:04 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2006-10-19 17:44:51 +00:00
|
|
|
source common.sh
|
|
|
|
|
2018-10-27 13:40:09 +00:00
|
|
|
clearStore
|
|
|
|
|
2006-10-19 17:44:51 +00:00
|
|
|
RESULT=$TEST_ROOT/result
|
|
|
|
|
2011-10-10 21:32:34 +00:00
|
|
|
dep=$(nix-build -o $RESULT check-refs.nix -A dep)
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test1 references dep, not itself.
|
2011-10-10 21:32:34 +00:00
|
|
|
test1=$(nix-build -o $RESULT check-refs.nix -A test1)
|
2021-12-09 15:26:46 +00:00
|
|
|
nix-store -q --references $test1 | grepQuietInverse $test1
|
|
|
|
nix-store -q --references $test1 | grepQuiet $dep
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test2 references src, not itself nor dep.
|
2011-10-10 21:32:34 +00:00
|
|
|
test2=$(nix-build -o $RESULT check-refs.nix -A test2)
|
2021-12-09 15:26:46 +00:00
|
|
|
nix-store -q --references $test2 | grepQuietInverse $test2
|
|
|
|
nix-store -q --references $test2 | grepQuietInverse $dep
|
|
|
|
nix-store -q --references $test2 | grepQuiet aux-ref
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test3 should fail (unallowed ref).
|
2014-08-21 19:50:19 +00:00
|
|
|
(! nix-build -o $RESULT check-refs.nix -A test3)
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test4 should succeed.
|
2011-10-10 21:32:34 +00:00
|
|
|
nix-build -o $RESULT check-refs.nix -A test4
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test5 should succeed.
|
2011-10-10 21:32:34 +00:00
|
|
|
nix-build -o $RESULT check-refs.nix -A test5
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test6 should fail (unallowed self-ref).
|
2014-08-21 19:50:19 +00:00
|
|
|
(! nix-build -o $RESULT check-refs.nix -A test6)
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test7 should succeed (allowed self-ref).
|
2011-10-10 21:32:34 +00:00
|
|
|
nix-build -o $RESULT check-refs.nix -A test7
|
2006-10-19 17:44:51 +00:00
|
|
|
|
|
|
|
# test8 should fail (toFile depending on derivation output).
|
2014-08-21 19:50:19 +00:00
|
|
|
(! nix-build -o $RESULT check-refs.nix -A test8)
|
2014-08-28 16:57:13 +00:00
|
|
|
|
|
|
|
# test9 should fail (disallowed reference).
|
|
|
|
(! nix-build -o $RESULT check-refs.nix -A test9)
|
|
|
|
|
|
|
|
# test10 should succeed (no disallowed references).
|
|
|
|
nix-build -o $RESULT check-refs.nix -A test10
|
2022-09-23 21:30:29 +00:00
|
|
|
|
|
|
|
if isDaemonNewer 2.12pre20230103; then
|
2023-05-12 07:56:39 +00:00
|
|
|
if ! isDaemonNewer 2.16.0; then
|
|
|
|
enableFeatures discard-references
|
|
|
|
restartDaemon
|
|
|
|
fi
|
2022-09-23 21:30:29 +00:00
|
|
|
|
|
|
|
# test11 should succeed.
|
|
|
|
test11=$(nix-build -o $RESULT check-refs.nix -A test11)
|
|
|
|
[[ -z $(nix-store -q --references "$test11") ]]
|
|
|
|
fi
|