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