forked from lix-project/lix
tests: move nix-shell related tests to subdir
This change feels kind of gross and reveals a fair bit about the
disorganization of our tests, but I think it makes parts of it a bit
better.
Change-Id: Idb8d9a00cbd75d5c156678c6b408b42b59d5e4d7
This commit is contained in:
parent
326cbecb61
commit
8497f0fe19
|
@ -3,5 +3,5 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
CONTENT_ADDRESSED=true
|
CONTENT_ADDRESSED=true
|
||||||
cd ..
|
cd ../nix-shell
|
||||||
source ./nix-shell.sh
|
source ./basic.sh
|
||||||
|
|
|
@ -24,7 +24,7 @@ EOF
|
||||||
|
|
||||||
# Create fake nixpkgs flake.
|
# Create fake nixpkgs flake.
|
||||||
mkdir -p $TEST_HOME/nixpkgs
|
mkdir -p $TEST_HOME/nixpkgs
|
||||||
cp ../config.nix ../shell.nix $TEST_HOME/nixpkgs
|
cp ../config.nix ../nix-shell/shell.nix $TEST_HOME/nixpkgs
|
||||||
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
||||||
{
|
{
|
||||||
outputs = {self}: {
|
outputs = {self}: {
|
||||||
|
|
|
@ -21,7 +21,7 @@ EOF
|
||||||
|
|
||||||
# Create fake nixpkgs flake.
|
# Create fake nixpkgs flake.
|
||||||
mkdir -p $TEST_HOME/nixpkgs
|
mkdir -p $TEST_HOME/nixpkgs
|
||||||
cp ../config.nix ../shell.nix $TEST_HOME/nixpkgs
|
cp ../config.nix ../nix-shell/shell.nix $TEST_HOME/nixpkgs
|
||||||
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
||||||
{
|
{
|
||||||
outputs = {self}: {
|
outputs = {self}: {
|
||||||
|
|
|
@ -25,6 +25,8 @@ config_nix_in = configure_file(
|
||||||
subdir('ca')
|
subdir('ca')
|
||||||
# Just configures `dyn-drv/config.nix.in`. Same as above.
|
# Just configures `dyn-drv/config.nix.in`. Same as above.
|
||||||
subdir('dyn-drv')
|
subdir('dyn-drv')
|
||||||
|
# Just configures `nix-shell/config.nix.in`. Same as above.
|
||||||
|
subdir('nix-shell')
|
||||||
|
|
||||||
subdir('plugins')
|
subdir('plugins')
|
||||||
subdir('test-libstoreconsumer')
|
subdir('test-libstoreconsumer')
|
||||||
|
@ -111,7 +113,8 @@ functional_tests_scripts = [
|
||||||
'hash.sh',
|
'hash.sh',
|
||||||
'gc-non-blocking.sh',
|
'gc-non-blocking.sh',
|
||||||
'check.sh',
|
'check.sh',
|
||||||
'nix-shell.sh',
|
'nix-shell/basic.sh',
|
||||||
|
'nix-shell/structured-attrs.sh',
|
||||||
'check-refs.sh',
|
'check-refs.sh',
|
||||||
'build-remote-input-addressed.sh',
|
'build-remote-input-addressed.sh',
|
||||||
'secure-drv-outputs.sh',
|
'secure-drv-outputs.sh',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
source common.sh
|
source ../common.sh
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
1
tests/functional/nix-shell/config.nix.in
Symbolic link
1
tests/functional/nix-shell/config.nix.in
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../config.nix.in
|
6
tests/functional/nix-shell/meson.build
Normal file
6
tests/functional/nix-shell/meson.build
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# test_confdata set from tests/functional/meson.build
|
||||||
|
configure_file(
|
||||||
|
input : 'config.nix.in',
|
||||||
|
output : 'config.nix',
|
||||||
|
configuration : test_confdata,
|
||||||
|
)
|
28
tests/functional/nix-shell/structured-attrs.sh
Normal file
28
tests/functional/nix-shell/structured-attrs.sh
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
source ../common.sh
|
||||||
|
|
||||||
|
# 27ce722638 required some incompatible changes to the nix file, so skip this
|
||||||
|
# tests for the older versions
|
||||||
|
requireDaemonNewerThan "2.4pre20210712"
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
export NIX_BUILD_SHELL=$SHELL
|
||||||
|
env NIX_PATH=nixpkgs=shell.nix nix-shell structured-attrs-shell.nix \
|
||||||
|
--run 'test "3" = "$(jq ".my.list|length" < $NIX_ATTRS_JSON_FILE)"'
|
||||||
|
|
||||||
|
nix develop -f structured-attrs-shell.nix -c bash -c 'test "3" = "$(jq ".my.list|length" < $NIX_ATTRS_JSON_FILE)"'
|
||||||
|
|
||||||
|
# `nix develop` is a slightly special way of dealing with environment vars, it parses
|
||||||
|
# these from a shell-file exported from a derivation. This is to test especially `outputs`
|
||||||
|
# (which is an associative array in thsi case) being fine.
|
||||||
|
nix develop -f structured-attrs-shell.nix -c bash -c 'test -n "$out"'
|
||||||
|
|
||||||
|
nix print-dev-env -f structured-attrs-shell.nix | grepQuiet 'NIX_ATTRS_JSON_FILE='
|
||||||
|
nix print-dev-env -f structured-attrs-shell.nix | grepQuiet 'NIX_ATTRS_SH_FILE='
|
||||||
|
nix print-dev-env -f shell.nix shellDrv | grepQuietInverse 'NIX_ATTRS_SH_FILE'
|
||||||
|
|
||||||
|
jsonOut="$(nix print-dev-env -f structured-attrs-shell.nix --json)"
|
||||||
|
|
||||||
|
test "$(<<<"$jsonOut" jq '.structuredAttrs|keys|.[]' -r)" = "$(printf ".attrs.json\n.attrs.sh")"
|
||||||
|
|
||||||
|
test "$(<<<"$jsonOut" jq '.variables.out.value' -r)" = "$(<<<"$jsonOut" jq '.structuredAttrs.".attrs.json"' -r | jq -r '.outputs.out')"
|
|
@ -12,24 +12,3 @@ nix-build structured-attrs.nix -A all -o $TEST_ROOT/result
|
||||||
|
|
||||||
[[ $(cat $TEST_ROOT/result/foo) = bar ]]
|
[[ $(cat $TEST_ROOT/result/foo) = bar ]]
|
||||||
[[ $(cat $TEST_ROOT/result-dev/foo) = foo ]]
|
[[ $(cat $TEST_ROOT/result-dev/foo) = foo ]]
|
||||||
|
|
||||||
export NIX_BUILD_SHELL=$SHELL
|
|
||||||
env NIX_PATH=nixpkgs=shell.nix nix-shell structured-attrs-shell.nix \
|
|
||||||
--run 'test "3" = "$(jq ".my.list|length" < $NIX_ATTRS_JSON_FILE)"'
|
|
||||||
|
|
||||||
nix develop -f structured-attrs-shell.nix -c bash -c 'test "3" = "$(jq ".my.list|length" < $NIX_ATTRS_JSON_FILE)"'
|
|
||||||
|
|
||||||
# `nix develop` is a slightly special way of dealing with environment vars, it parses
|
|
||||||
# these from a shell-file exported from a derivation. This is to test especially `outputs`
|
|
||||||
# (which is an associative array in thsi case) being fine.
|
|
||||||
nix develop -f structured-attrs-shell.nix -c bash -c 'test -n "$out"'
|
|
||||||
|
|
||||||
nix print-dev-env -f structured-attrs-shell.nix | grepQuiet 'NIX_ATTRS_JSON_FILE='
|
|
||||||
nix print-dev-env -f structured-attrs-shell.nix | grepQuiet 'NIX_ATTRS_SH_FILE='
|
|
||||||
nix print-dev-env -f shell.nix shellDrv | grepQuietInverse 'NIX_ATTRS_SH_FILE'
|
|
||||||
|
|
||||||
jsonOut="$(nix print-dev-env -f structured-attrs-shell.nix --json)"
|
|
||||||
|
|
||||||
test "$(<<<"$jsonOut" jq '.structuredAttrs|keys|.[]' -r)" = "$(printf ".attrs.json\n.attrs.sh")"
|
|
||||||
|
|
||||||
test "$(<<<"$jsonOut" jq '.variables.out.value' -r)" = "$(<<<"$jsonOut" jq '.structuredAttrs.".attrs.json"' -r | jq -r '.outputs.out')"
|
|
||||||
|
|
Loading…
Reference in a new issue