tests/functional/lang: Don't pipe input into stdin
Back in the days, this used to be the modus operandi, but then, still many but less years ago, Eelco came along and changed it to passing in the actual file. Of course, no motivation was provided, and it was only done on half of the test runners for some reason, leaving us to wonder what the true intentions of this code are … Anyways, with this commit now everything standardises on passing in the file by path instead of via stdin. Motivation: - We need to `sed` out the path anyways for various other reasons, including import tests and path value tests - Given that, the presumed primary motivation for using stdin in the first place becomes moot - Bonus points for giving better error messages, especially in tests that involve multiple input files Change-Id: Ic6de1ec24f4c4d3c05e33d1ee053614784677513
This commit is contained in:
@@ -47,8 +47,9 @@ for i in parse-fail-*.nix; do
|
||||
if test -e "$i.flags"; then
|
||||
read -r -a flags < "$i.flags"
|
||||
fi
|
||||
if expectStderr 1 nix-instantiate --parse "${flags[@]}" - < "$i.nix" > "$i.err"
|
||||
if expectStderr 1 nix-instantiate --parse "${flags[@]}" "$i.nix" > "$i.err"
|
||||
then
|
||||
sed -i "s!$(pwd)!/pwd!g" "$i.err"
|
||||
diffAndAccept "$i" err err.exp
|
||||
else
|
||||
echo "FAIL: $i shouldn't parse"
|
||||
@@ -65,11 +66,11 @@ for i in parse-okay-*.nix; do
|
||||
read -r -a flags < "$i.flags"
|
||||
fi
|
||||
if
|
||||
expect 0 nix-instantiate --parse "${flags[@]}" - < "$i.nix" \
|
||||
expect 0 nix-instantiate --parse "${flags[@]}" "$i.nix" \
|
||||
1> "$i.out" \
|
||||
2> "$i.err"
|
||||
then
|
||||
sed "s!$(pwd)!/pwd!g" "$i.out" "$i.err"
|
||||
sed -i "s!$(pwd)!/pwd!g" "$i.out" "$i.err"
|
||||
yq --in-place --yaml-output '.' "$i.out"
|
||||
diffAndAccept "$i" out exp
|
||||
diffAndAccept "$i" err err.exp
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
warning: CR (`\r`) and CRLF (`\r\n`) line endings are not supported. Please inspect the file and normalize it to use LF (`\n`) line endings instead. Use --extra-deprecated-features cr-line-endings to silence this warning.
|
||||
at «stdin»:7:21:
|
||||
at /pwd/parse-okay-crlf.nix:7:21:
|
||||
6| x =
|
||||
7| # Dit is een test.
|
||||
| ^
|
||||
8| y;
|
||||
error: CR (`\r`) and CRLF (`\r\n`) line endings are not supported. Please inspect the file and normalize it to use LF (`\n`) line endings instead. Use --extra-deprecated-features cr-line-endings to silence this warning.
|
||||
at «stdin»:14:15:
|
||||
at /pwd/parse-okay-crlf.nix:14:15:
|
||||
13| # translated to LF.
|
||||
14| foo = "multi
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'x' already defined at «stdin»:1:3
|
||||
at «stdin»:3:3:
|
||||
error: attribute 'x' already defined at /pwd/parse-fail-dup-attrs-1.nix:1:3
|
||||
at /pwd/parse-fail-dup-attrs-1.nix:3:3:
|
||||
2| y = 456;
|
||||
3| x = 789;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:18:
|
||||
error: attribute 'x' already defined at /pwd/parse-fail-dup-attrs-2.nix:9:5
|
||||
at /pwd/parse-fail-dup-attrs-2.nix:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:18:
|
||||
error: attribute 'x' already defined at /pwd/parse-fail-dup-attrs-3.nix:9:5
|
||||
at /pwd/parse-fail-dup-attrs-3.nix:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'services.ssh.port' already defined at «stdin»:2:3
|
||||
at «stdin»:3:3:
|
||||
error: attribute 'services.ssh.port' already defined at /pwd/parse-fail-dup-attrs-4.nix:2:3
|
||||
at /pwd/parse-fail-dup-attrs-4.nix:3:3:
|
||||
2| services.ssh.port = 22;
|
||||
3| services.ssh.port = 23;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'x' already defined at «stdin»:6:13
|
||||
at «stdin»:7:13:
|
||||
error: attribute 'x' already defined at /pwd/parse-fail-dup-attrs-7.nix:6:13
|
||||
at /pwd/parse-fail-dup-attrs-7.nix:7:13:
|
||||
6| inherit x;
|
||||
7| inherit x;
|
||||
| ^
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error: duplicate formal function argument 'x'
|
||||
at «stdin»:1:8:
|
||||
at /pwd/parse-fail-dup-formals.nix:1:8:
|
||||
1| {x, y, x}: x
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: syntax error, unexpected end of file, expecting '"'
|
||||
at «stdin»:3:6:
|
||||
at /pwd/parse-fail-eof-in-string.nix:3:6:
|
||||
2| # Note that this file must not end with a newline.
|
||||
3| a 1"$
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: syntax error, unexpected end of file, expecting expression
|
||||
at «stdin»:3:1:
|
||||
at /pwd/parse-fail-eof-pos.nix:3:1:
|
||||
2| # no content
|
||||
3|
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'invalid'
|
||||
at «stdin»:2:1:
|
||||
at /pwd/parse-fail-eol-1.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'invalid'
|
||||
at «stdin»:2:1:
|
||||
at /pwd/parse-fail-eol-2.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'invalid'
|
||||
at «stdin»:2:1:
|
||||
at /pwd/parse-fail-eol-3.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'z' already defined at «stdin»:3:16
|
||||
at «stdin»:2:3:
|
||||
error: attribute 'z' already defined at /pwd/parse-fail-mixed-nested-attrs1.nix:3:16
|
||||
at /pwd/parse-fail-mixed-nested-attrs1.nix:2:3:
|
||||
1| {
|
||||
2| x.z = 3;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: attribute 'y' already defined at «stdin»:3:9
|
||||
at «stdin»:2:3:
|
||||
error: attribute 'y' already defined at /pwd/parse-fail-mixed-nested-attrs2.nix:3:9
|
||||
at /pwd/parse-fail-mixed-nested-attrs2.nix:2:3:
|
||||
1| {
|
||||
2| x.y.y = 3;
|
||||
| ^
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
error: path has a trailing slash
|
||||
at «stdin»:6:12:
|
||||
at /pwd/parse-fail-path-slash.nix:6:12:
|
||||
5| # and https://nixos.org/nix-dev/2016-June/020829.html
|
||||
6| /nix/store/
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate formal function argument 'args'
|
||||
at «stdin»:1:1:
|
||||
at /pwd/parse-fail-patterns-1.nix:1:1:
|
||||
1| args@{args, x, y, z}: x
|
||||
| ^
|
||||
2|
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'gcc'
|
||||
at «stdin»:9:11:
|
||||
at /pwd/parse-fail-regression-20060610.nix:9:11:
|
||||
8| ({
|
||||
9| inherit gcc;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'x'
|
||||
at «stdin»:1:3:
|
||||
at /pwd/parse-fail-set.nix:1:3:
|
||||
1| 8.x
|
||||
| ^
|
||||
2|
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: syntax error, expecting '}'
|
||||
at «stdin»:3:13:
|
||||
at /pwd/parse-fail-undef-var-2.nix:3:13:
|
||||
2|
|
||||
3| f = {x, y : ["baz" "bar" z "bat"]}: x + y;
|
||||
| ^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: undefined variable 'y'
|
||||
at «stdin»:1:4:
|
||||
at /pwd/parse-fail-undef-var.nix:1:4:
|
||||
1| x: y
|
||||
| ^
|
||||
2|
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: syntax error, expecting end of file
|
||||
at «stdin»:1:5:
|
||||
at /pwd/parse-fail-utf8.nix:1:5:
|
||||
1| 123 é 4
|
||||
| ^
|
||||
2|
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
warning: __overrides attributes are deprecated and will be removed in the future. Use --extra-deprecated-features rec-set-overrides to silence this warning.
|
||||
at «stdin»:3:17:
|
||||
at /pwd/parse-okay-rec-set-override-warning.nix:3:17:
|
||||
2| # Should warn
|
||||
3| { a = rec {}; a.__overrides = {}; }
|
||||
| ^
|
||||
4| rec { __overrides = {}; }
|
||||
warning: __overrides attributes are deprecated and will be removed in the future. Use --extra-deprecated-features rec-set-overrides to silence this warning.
|
||||
at «stdin»:4:9:
|
||||
at /pwd/parse-okay-rec-set-override-warning.nix:4:9:
|
||||
3| { a = rec {}; a.__overrides = {}; }
|
||||
4| rec { __overrides = {}; }
|
||||
| ^
|
||||
|
||||
Reference in New Issue
Block a user