1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

shellcheck fix: tests/functional/gc-auto.sh

This commit is contained in:
Farid Zakaria 2025-09-29 09:18:50 -07:00
parent 08a82f4682
commit 4192ca9131
2 changed files with 13 additions and 10 deletions

View file

@ -106,7 +106,6 @@
enable = true; enable = true;
excludes = [ excludes = [
# We haven't linted these files yet # We haven't linted these files yet
''^tests/functional/gc-auto\.sh$''
''^tests/functional/gc-concurrent\.builder\.sh$'' ''^tests/functional/gc-concurrent\.builder\.sh$''
''^tests/functional/gc-concurrent\.sh$'' ''^tests/functional/gc-concurrent\.sh$''
''^tests/functional/gc-concurrent2\.builder\.sh$'' ''^tests/functional/gc-concurrent2\.builder\.sh$''

View file

@ -2,22 +2,26 @@
source common.sh source common.sh
# shellcheck disable=SC1111
needLocalStore "“min-free” and “max-free” are daemon options" needLocalStore "“min-free” and “max-free” are daemon options"
TODO_NixOS TODO_NixOS
clearStore clearStore
# shellcheck disable=SC2034
garbage1=$(nix store add-path --name garbage1 ./nar-access.sh) garbage1=$(nix store add-path --name garbage1 ./nar-access.sh)
# shellcheck disable=SC2034
garbage2=$(nix store add-path --name garbage2 ./nar-access.sh) garbage2=$(nix store add-path --name garbage2 ./nar-access.sh)
# shellcheck disable=SC2034
garbage3=$(nix store add-path --name garbage3 ./nar-access.sh) garbage3=$(nix store add-path --name garbage3 ./nar-access.sh)
ls -l $garbage3 ls -l "$garbage3"
POSIXLY_CORRECT=1 du $garbage3 POSIXLY_CORRECT=1 du "$garbage3"
fake_free=$TEST_ROOT/fake-free fake_free=$TEST_ROOT/fake-free
export _NIX_TEST_FREE_SPACE_FILE=$fake_free export _NIX_TEST_FREE_SPACE_FILE=$fake_free
echo 1100 > $fake_free echo 1100 > "$fake_free"
fifoLock=$TEST_ROOT/fifoLock fifoLock=$TEST_ROOT/fifoLock
mkfifo "$fifoLock" mkfifo "$fifoLock"
@ -65,11 +69,11 @@ with import ${config_nix}; mkDerivation {
EOF EOF
) )
nix build --impure -v -o $TEST_ROOT/result-A -L --expr "$expr" \ nix build --impure -v -o "$TEST_ROOT"/result-A -L --expr "$expr" \
--min-free 1K --max-free 2K --min-free-check-interval 1 & --min-free 1K --max-free 2K --min-free-check-interval 1 &
pid1=$! pid1=$!
nix build --impure -v -o $TEST_ROOT/result-B -L --expr "$expr2" \ nix build --impure -v -o "$TEST_ROOT"/result-B -L --expr "$expr2" \
--min-free 1K --max-free 2K --min-free-check-interval 1 & --min-free 1K --max-free 2K --min-free-check-interval 1 &
pid2=$! pid2=$!
@ -77,9 +81,9 @@ pid2=$!
# If the first build fails, we need to postpone the failure to still allow # If the first build fails, we need to postpone the failure to still allow
# the second one to finish # the second one to finish
wait "$pid1" || FIRSTBUILDSTATUS=$? wait "$pid1" || FIRSTBUILDSTATUS=$?
echo "unlock" > $fifoLock echo "unlock" > "$fifoLock"
( exit ${FIRSTBUILDSTATUS:-0} ) ( exit "${FIRSTBUILDSTATUS:-0}" )
wait "$pid2" wait "$pid2"
[[ foo = $(cat $TEST_ROOT/result-A/bar) ]] [[ foo = $(cat "$TEST_ROOT"/result-A/bar) ]]
[[ foo = $(cat $TEST_ROOT/result-B/bar) ]] [[ foo = $(cat "$TEST_ROOT"/result-B/bar) ]]