tests/functional-lang: Small cleanup of flagfiles handling

Flag files now properly work for all tests.

Change-Id: If652235960e8cf4120270a1b974c17586a31a157
This commit is contained in:
piegames 2024-08-25 10:22:30 +02:00
parent 52b64662a4
commit 580df9bdb3

View file

@ -41,7 +41,12 @@ badExitCode=0
for i in lang/parse-fail-*.nix; do for i in lang/parse-fail-*.nix; do
echo "parsing $i (should fail)"; echo "parsing $i (should fail)";
i=$(basename "$i" .nix) i=$(basename "$i" .nix)
if expectStderr 1 nix-instantiate --parse - < "lang/$i.nix" > "lang/$i.err"
declare -a flags=()
if test -e "lang/$i.flags"; then
read -r -a flags < "lang/$i.flags"
fi
if expectStderr 1 nix-instantiate --parse "${flags[@]}" - < "lang/$i.nix" > "lang/$i.err"
then then
diffAndAccept "$i" err err.exp diffAndAccept "$i" err err.exp
else else
@ -54,13 +59,12 @@ for i in lang/parse-okay-*.nix; do
echo "parsing $i (should succeed)"; echo "parsing $i (should succeed)";
i=$(basename "$i" .nix) i=$(basename "$i" .nix)
if [ -e "lang/$i.flags" ]; then declare -a flags=()
extraArgs="$(cat "lang/$i.flags")" if test -e "lang/$i.flags"; then
else read -r -a flags < "lang/$i.flags"
extraArgs=""
fi fi
if if
expect 0 nix-instantiate --parse ${extraArgs-} - < "lang/$i.nix" \ expect 0 nix-instantiate --parse "${flags[@]}" - < "lang/$i.nix" \
1> "lang/$i.out" \ 1> "lang/$i.out" \
2> "lang/$i.err" 2> "lang/$i.err"
then then
@ -77,13 +81,12 @@ for i in lang/eval-fail-*.nix; do
echo "evaluating $i (should fail)"; echo "evaluating $i (should fail)";
i=$(basename "$i" .nix) i=$(basename "$i" .nix)
if [ -e "lang/$i.flags" ]; then declare -a flags=()
extraArgs="$(cat "lang/$i.flags")" if test -e "lang/$i.flags"; then
else read -r -a flags < "lang/$i.flags"
extraArgs=""
fi fi
if if
expectStderr 1 nix-instantiate --eval --strict --show-trace ${extraArgs-} "lang/$i.nix" \ expectStderr 1 nix-instantiate --eval --strict --show-trace "${flags[@]}" "lang/$i.nix" \
| sed "s!$(pwd)!/pwd!g" > "lang/$i.err" | sed "s!$(pwd)!/pwd!g" > "lang/$i.err"
then then
diffAndAccept "$i" err err.exp diffAndAccept "$i" err err.exp
@ -97,14 +100,13 @@ for i in lang/eval-okay-*.nix; do
echo "evaluating $i (should succeed)"; echo "evaluating $i (should succeed)";
i=$(basename "$i" .nix) i=$(basename "$i" .nix)
if [ -e "lang/$i.flags" ]; then declare -a flags=()
extraArgs="$(cat "lang/$i.flags")" if test -e "lang/$i.flags"; then
else read -r -a flags < "lang/$i.flags"
extraArgs=""
fi fi
if test -e "lang/$i.exp.xml"; then if test -e "lang/$i.exp.xml"; then
if expect 0 nix-instantiate --eval --xml --no-location --strict ${extraArgs-} \ if expect 0 nix-instantiate --eval --xml --no-location --strict "${flags[@]}" \
"lang/$i.nix" > "lang/$i.out.xml" "lang/$i.nix" > "lang/$i.out.xml"
then then
diffAndAccept "$i" out.xml exp.xml diffAndAccept "$i" out.xml exp.xml
@ -113,11 +115,6 @@ for i in lang/eval-okay-*.nix; do
badExitCode=1 badExitCode=1
fi fi
elif test ! -e "lang/$i.exp-disabled"; then elif test ! -e "lang/$i.exp-disabled"; then
declare -a flags=()
if test -e "lang/$i.flags"; then
read -r -a flags < "lang/$i.flags"
fi
if if
expect 0 env \ expect 0 env \
NIX_PATH=lang/dir3:lang/dir4 \ NIX_PATH=lang/dir3:lang/dir4 \