mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 08:12:29 +00:00
tests/shell.sh: Check that env is mostly unmodified
This commit is contained in:
parent
68b8a28bc4
commit
316b58dd5f
@ -21,6 +21,25 @@ nix shell -f shell-hello.nix hello-symlink -c hello | grep 'Hello World'
|
|||||||
# Test that symlinks outside of the store don't work.
|
# Test that symlinks outside of the store don't work.
|
||||||
expect 1 nix shell -f shell-hello.nix forbidden-symlink -c hello 2>&1 | grepQuiet "is not in the Nix store"
|
expect 1 nix shell -f shell-hello.nix forbidden-symlink -c hello 2>&1 | grepQuiet "is not in the Nix store"
|
||||||
|
|
||||||
|
# Test that we're not setting any more environment variables than necessary.
|
||||||
|
# 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
|
||||||
|
# Remove/reset variables we expect to be different.
|
||||||
|
# - PATH is modified by nix shell
|
||||||
|
# - _ is set by bash and is expectedf to differ because it contains the original command
|
||||||
|
# - __CF_USER_TEXT_ENCODING is set by macOS and is beyond our control
|
||||||
|
sed -i \
|
||||||
|
-e 's/PATH=.*/PATH=.../' \
|
||||||
|
-e 's/_=.*/_=.../' \
|
||||||
|
-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
|
||||||
|
|
||||||
if isDaemonNewer "2.20.0pre20231220"; then
|
if isDaemonNewer "2.20.0pre20231220"; then
|
||||||
# Test that command line attribute ordering is reflected in the PATH
|
# Test that command line attribute ordering is reflected in the PATH
|
||||||
# https://github.com/NixOS/nix/issues/7905
|
# https://github.com/NixOS/nix/issues/7905
|
||||||
|
Loading…
Reference in New Issue
Block a user