1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00

Expand shellcheck coverage in functional tests

Ref NixOS/nix#10795
This commit is contained in:
Tim Van Baak 2024-10-29 21:33:28 -07:00
parent a8e600e386
commit a75b082a28
12 changed files with 159 additions and 163 deletions

View file

@ -27,8 +27,8 @@ expect 1 nix shell -f shell-hello.nix forbidden-symlink -c hello 2>&1 | grepQuie
# For instance, we might set an environment variable temporarily to affect some
# initialization or whatnot, but this must not leak into the environment of the
# command being run.
env > $TEST_ROOT/expected-env
nix shell -f shell-hello.nix hello -c env > $TEST_ROOT/actual-env
env > "$TEST_ROOT/expected-env"
nix shell -f shell-hello.nix hello -c env > "$TEST_ROOT/actual-env"
# Remove/reset variables we expect to be different.
# - PATH is modified by nix shell
# - we unset TMPDIR on macOS if it contains /var/folders
@ -39,10 +39,10 @@ sed -i \
-e 's/_=.*/_=.../' \
-e '/^TMPDIR=\/var\/folders\/.*/d' \
-e '/^__CF_USER_TEXT_ENCODING=.*$/d' \
$TEST_ROOT/expected-env $TEST_ROOT/actual-env
sort $TEST_ROOT/expected-env > $TEST_ROOT/expected-env.sorted
sort $TEST_ROOT/actual-env > $TEST_ROOT/actual-env.sorted
diff $TEST_ROOT/expected-env.sorted $TEST_ROOT/actual-env.sorted
"$TEST_ROOT/expected-env" "$TEST_ROOT/actual-env"
sort "$TEST_ROOT/expected-env" > "$TEST_ROOT/expected-env.sorted"
sort "$TEST_ROOT/actual-env" > "$TEST_ROOT/actual-env.sorted"
diff "$TEST_ROOT/expected-env.sorted" "$TEST_ROOT/actual-env.sorted"
if isDaemonNewer "2.20.0pre20231220"; then
# Test that command line attribute ordering is reflected in the PATH
@ -53,8 +53,8 @@ fi
requireSandboxSupport
chmod -R u+w $TEST_ROOT/store0 || true
rm -rf $TEST_ROOT/store0
chmod -R u+w "$TEST_ROOT/store0" || true
rm -rf "$TEST_ROOT/store0"
clearStore
@ -64,10 +64,10 @@ path=$(nix eval --raw -f shell-hello.nix hello)
# visible in the sandbox.
nix shell --sandbox-build-dir /build-tmp \
--sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' \
--store $TEST_ROOT/store0 -f shell-hello.nix hello -c hello | grep 'Hello World'
--store "$TEST_ROOT/store0" -f shell-hello.nix hello -c hello | grep 'Hello World'
path2=$(nix shell --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store $TEST_ROOT/store0 -f shell-hello.nix hello -c $SHELL -c 'type -p hello')
path2=$(nix shell --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store "$TEST_ROOT/store0" -f shell-hello.nix hello -c "$SHELL" -c 'type -p hello')
[[ $path/bin/hello = $path2 ]]
[[ "$path/bin/hello" = "$path2" ]]
[[ -e $TEST_ROOT/store0/nix/store/$(basename $path)/bin/hello ]]
[[ -e $TEST_ROOT/store0/nix/store/$(basename "$path")/bin/hello ]]