1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

shellcheck fix: tests/functional/fixed

This commit is contained in:
Farid Zakaria 2025-09-25 13:16:47 -07:00
parent 4cec876319
commit f8e351cd94
4 changed files with 21 additions and 19 deletions

View file

@ -106,9 +106,6 @@
enable = true;
excludes = [
# We haven't linted these files yet
''^tests/functional/fixed\.builder1\.sh$''
''^tests/functional/fixed\.builder2\.sh$''
''^tests/functional/fixed\.sh$''
''^tests/functional/flakes/absolute-paths\.sh$''
''^tests/functional/flakes/check\.sh$''
''^tests/functional/flakes/config\.sh$''

View file

@ -1,3 +1,5 @@
# shellcheck shell=bash
if test "$IMPURE_VAR1" != "foo"; then exit 1; fi
if test "$IMPURE_VAR2" != "bar"; then exit 1; fi
echo "Hello World!" > $out
# shellcheck disable=SC2154
echo "Hello World!" > "$out"

View file

@ -1,6 +1,9 @@
echo dummy: $dummy
# shellcheck shell=bash
# shellcheck disable=SC2154
echo dummy: "$dummy"
if test -n "$dummy"; then sleep 2; fi
mkdir $out
mkdir $out/bla
echo "Hello World!" > $out/foo
ln -s foo $out/bar
# shellcheck disable=SC2154
mkdir "$out"
mkdir "$out"/bla
echo "Hello World!" > "$out"/foo
ln -s foo "$out"/bar

View file

@ -6,7 +6,7 @@ TODO_NixOS
clearStore
path=$(nix-store -q $(nix-instantiate fixed.nix -A good.0))
path=$(nix-store -q "$(nix-instantiate fixed.nix -A good.0)")
echo 'testing bad...'
nix-build fixed.nix -A bad --no-out-link && fail "should fail"
@ -14,7 +14,7 @@ nix-build fixed.nix -A bad --no-out-link && fail "should fail"
# Building with the bad hash should produce the "good" output path as
# a side-effect.
[[ -e $path ]]
nix path-info --json $path | grep fixed:md5:2qk15sxzzjlnpjk9brn7j8ppcd
nix path-info --json "$path" | grep fixed:md5:2qk15sxzzjlnpjk9brn7j8ppcd
echo 'testing good...'
nix-build fixed.nix -A good --no-out-link
@ -37,7 +37,7 @@ fi
# While we're at it, check attribute selection a bit more.
echo 'testing attribute selection...'
test $(nix-instantiate fixed.nix -A good.1 | wc -l) = 1
test "$(nix-instantiate fixed.nix -A good.1 | wc -l)" = 1
# Test parallel builds of derivations that produce the same output.
# Only one should run at the same time.
@ -51,16 +51,16 @@ echo 'testing sameAsAdd...'
out=$(nix-build fixed.nix -A sameAsAdd --no-out-link)
# This is what fixed.builder2 produces...
rm -rf $TEST_ROOT/fixed
mkdir $TEST_ROOT/fixed
mkdir $TEST_ROOT/fixed/bla
echo "Hello World!" > $TEST_ROOT/fixed/foo
ln -s foo $TEST_ROOT/fixed/bar
rm -rf "$TEST_ROOT"/fixed
mkdir "$TEST_ROOT"/fixed
mkdir "$TEST_ROOT"/fixed/bla
echo "Hello World!" > "$TEST_ROOT"/fixed/foo
ln -s foo "$TEST_ROOT"/fixed/bar
out2=$(nix-store --add $TEST_ROOT/fixed)
out2=$(nix-store --add "$TEST_ROOT"/fixed)
[ "$out" = "$out2" ]
out3=$(nix-store --add-fixed --recursive sha256 $TEST_ROOT/fixed)
out3=$(nix-store --add-fixed --recursive sha256 "$TEST_ROOT"/fixed)
[ "$out" = "$out3" ]
out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed)