diff --git a/tests/functional/derivation-instantiate.sh b/tests/functional/derivation-instantiate.sh index fea0030c5..b46b177bc 100755 --- a/tests/functional/derivation-instantiate.sh +++ b/tests/functional/derivation-instantiate.sh @@ -7,38 +7,38 @@ TODO_NixOS clearStore drvPath=$(nix derivation instantiate --no-link --file simple.nix) -test -f $drvPath -nix-store --delete $drvPath -! test -f $drvPath +test -f "$drvPath" +nix-store --delete "$drvPath" +if test -f "$drvPath"; then false; fi drvPath=$(nix derivation instantiate --file simple.nix) -test -f $drvPath +test -f "$drvPath" test -e drv -nix-store --gc --print-roots | grep $drvPath -nix-store --gc --print-live | grep $drvPath -! nix-store --delete $drvPath -test -f $drvPath -[ "$(nix-store -q --roots $drvPath)" = "$(realpath --no-symlinks drv) -> $drvPath" ] +nix-store --gc --print-roots | grep "$drvPath" +nix-store --gc --print-live | grep "$drvPath" +if nix-store --delete "$drvPath"; then false; fi +test -f "$drvPath" +[ "$(nix-store -q --roots "$drvPath")" = "$(realpath --no-symlinks drv) -> $drvPath" ] rm drv -nix-store --delete $drvPath -! test -f $drvPath +nix-store --delete "$drvPath" +if test -f "$drvPath"; then false; fi drvPath=$(nix derivation instantiate --out-link foobar --file simple.nix) test -e foobar -[ "$(nix-store -q --roots $drvPath)" = "$(realpath --no-symlinks foobar) -> $drvPath" ] +[ "$(nix-store -q --roots "$drvPath")" = "$(realpath --no-symlinks foobar) -> $drvPath" ] rm foobar -nix-store --delete $drvPath +nix-store --delete "$drvPath" drvPathJson=$(nix derivation instantiate --json --no-link --file simple.nix) -[ "$drvPathJson" = '{"'"$drvPath"'":{}}' ] -nix-store --delete $drvPath +[ "$drvPathJson" = "{\"$drvPath\":{}}" ] +nix-store --delete "$drvPath" -drvPaths=($(nix derivation instantiate --json --out-link multidrv --file check.nix | jq 'keys|.[]' -r)) +mapfile -t drvPaths < <(nix derivation instantiate --json --out-link multidrv --file check.nix | jq 'keys|.[]' -r) roots=(./multidrv*) [ "${#roots[@]}" -gt 1 ] [ "${#roots[@]}" -eq "${#drvPaths[@]}" ] -rootedPaths=($(readlink "${roots[@]}")) +mapfile -t rootedPaths < <(readlink "${roots[@]}") [ "${rootedPaths[*]}" = "${drvPaths[*]}" ] -rm multidrv* +rm -f multidrv* nix-collect-garbage