From 75df03204b2505e1132fa67a45ae589239ccdaec Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Mon, 29 Sep 2025 09:21:47 -0700 Subject: [PATCH] shellcheck fix: tests/functional/gc-concurrent.sh --- maintainers/flake-module.nix | 1 - tests/functional/gc-concurrent.sh | 34 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/maintainers/flake-module.nix b/maintainers/flake-module.nix index 65c94c415..a2edadebb 100644 --- a/maintainers/flake-module.nix +++ b/maintainers/flake-module.nix @@ -106,7 +106,6 @@ enable = true; excludes = [ # We haven't linted these files yet - ''^tests/functional/gc-concurrent\.sh$'' ''^tests/functional/gc-concurrent2\.builder\.sh$'' ''^tests/functional/gc-non-blocking\.sh$'' ''^tests/functional/hash-convert\.sh$'' diff --git a/tests/functional/gc-concurrent.sh b/tests/functional/gc-concurrent.sh index df180b14f..dcfcea3e9 100755 --- a/tests/functional/gc-concurrent.sh +++ b/tests/functional/gc-concurrent.sh @@ -10,54 +10,58 @@ lockFifo1=$TEST_ROOT/test1.fifo mkfifo "$lockFifo1" drvPath1=$(nix-instantiate gc-concurrent.nix -A test1 --argstr lockFifo "$lockFifo1") -outPath1=$(nix-store -q $drvPath1) +outPath1=$(nix-store -q "$drvPath1") drvPath2=$(nix-instantiate gc-concurrent.nix -A test2) -outPath2=$(nix-store -q $drvPath2) +outPath2=$(nix-store -q "$drvPath2") drvPath3=$(nix-instantiate simple.nix) -outPath3=$(nix-store -r $drvPath3) +outPath3=$(nix-store -r "$drvPath3") -(! test -e $outPath3.lock) -touch $outPath3.lock +# shellcheck disable=SC2235 +(! test -e "$outPath3".lock) +touch "$outPath3".lock rm -f "$NIX_STATE_DIR"/gcroots/foo* -ln -s $drvPath2 "$NIX_STATE_DIR/gcroots/foo" -ln -s $outPath3 "$NIX_STATE_DIR/gcroots/foo2" +ln -s "$drvPath2" "$NIX_STATE_DIR/gcroots/foo" +ln -s "$outPath3" "$NIX_STATE_DIR/gcroots/foo2" # Start build #1 in the background. It starts immediately. nix-store -rvv "$drvPath1" & pid1=$! # Wait for the build of $drvPath1 to start -cat $lockFifo1 +cat "$lockFifo1" # Run the garbage collector while the build is running. nix-collect-garbage # Unlock the build of $drvPath1 -echo "" > $lockFifo1 +echo "" > "$lockFifo1" echo waiting for pid $pid1 to finish... wait $pid1 # Check that the root of build #1 and its dependencies haven't been # deleted. The should not be deleted by the GC because they were # being built during the GC. -cat $outPath1/foobar -cat $outPath1/input-2/bar +cat "$outPath1"/foobar +cat "$outPath1"/input-2/bar # Check that the build build $drvPath2 succeeds. # It should succeed because the derivation is a GC root. nix-store -rvv "$drvPath2" -cat $outPath2/foobar +cat "$outPath2"/foobar rm -f "$NIX_STATE_DIR"/gcroots/foo* # The collector should have deleted lock files for paths that have # been built previously. -(! test -e $outPath3.lock) +# shellcheck disable=SC2235 +(! test -e "$outPath3".lock) # If we run the collector now, it should delete outPath1/2. nix-collect-garbage -(! test -e $outPath1) -(! test -e $outPath2) +# shellcheck disable=SC2235 +(! test -e "$outPath1") +# shellcheck disable=SC2235 +(! test -e "$outPath2")