mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
print-dev-env: test the case when PATH is empty
This commit is contained in:
parent
526bdbda3c
commit
e210de4799
1 changed files with 34 additions and 7 deletions
|
@ -94,16 +94,43 @@ echo foo | nix develop -f "$shellDotNix" shellDrv -c cat | grepQuiet foo
|
||||||
nix develop -f "$shellDotNix" shellDrv -c echo foo |& grepQuiet foo
|
nix develop -f "$shellDotNix" shellDrv -c echo foo |& grepQuiet foo
|
||||||
|
|
||||||
# Test 'nix print-dev-env'.
|
# Test 'nix print-dev-env'.
|
||||||
[[ $(nix print-dev-env -f "$shellDotNix" shellDrv --json | jq -r .variables.arr1.value[2]) = '3 4' ]]
|
|
||||||
|
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
|
||||||
|
function finish {
|
||||||
|
rm -rf "$scratch"
|
||||||
|
}
|
||||||
|
trap finish EXIT
|
||||||
|
|
||||||
|
nix print-dev-env -f "$shellDotNix" shellDrv > "$scratch/dev-env.sh"
|
||||||
|
nix print-dev-env -f "$shellDotNix" shellDrv --json > "$scratch/dev-env.json"
|
||||||
|
|
||||||
|
# Ensure `nix print-dev-env --json` contains variable assignments.
|
||||||
|
[[ $(jq -r .variables.arr1.value[2] "$scratch/dev-env.json") = '3 4' ]]
|
||||||
|
|
||||||
|
# Run tests involving `source <(nix print-dev-inv)` in subshells to avoid modifying the current
|
||||||
|
# environment.
|
||||||
|
|
||||||
set +u # FIXME: Make print-dev-env `set -u` compliant (issue #7951)
|
set +u # FIXME: Make print-dev-env `set -u` compliant (issue #7951)
|
||||||
|
|
||||||
source <(nix print-dev-env -f "$shellDotNix" shellDrv)
|
# Ensure `source <(nix print-dev-env)` modifies the environment.
|
||||||
[[ -n $stdenv ]]
|
(
|
||||||
[[ ${arr1[2]} = "3 4" ]]
|
path=$PATH
|
||||||
[[ ${arr2[1]} = $'\n' ]]
|
source "$scratch/dev-env.sh"
|
||||||
[[ ${arr2[2]} = $'x\ny' ]]
|
[[ -n $stdenv ]]
|
||||||
[[ $(fun) = blabla ]]
|
[[ ${arr1[2]} = "3 4" ]]
|
||||||
|
[[ ${arr2[1]} = $'\n' ]]
|
||||||
|
[[ ${arr2[2]} = $'x\ny' ]]
|
||||||
|
[[ $(fun) = blabla ]]
|
||||||
|
[[ $PATH = $(jq -r .variables.PATH.value "$scratch/dev-env.json"):$path ]]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ensure `source <(nix print-dev-env)` handles the case when PATH is empty.
|
||||||
|
(
|
||||||
|
path=$PATH
|
||||||
|
PATH=
|
||||||
|
source "$scratch/dev-env.sh"
|
||||||
|
[[ $PATH = $(PATH=$path jq -r .variables.PATH.value "$scratch/dev-env.json") ]]
|
||||||
|
)
|
||||||
|
|
||||||
# Test nix-shell with ellipsis and no `inNixShell` argument (for backwards compat with old nixpkgs)
|
# Test nix-shell with ellipsis and no `inNixShell` argument (for backwards compat with old nixpkgs)
|
||||||
cat >$TEST_ROOT/shell-ellipsis.nix <<EOF
|
cat >$TEST_ROOT/shell-ellipsis.nix <<EOF
|
||||||
|
|
Loading…
Reference in a new issue