tests/functional2/lang: migrated first tests
Change-Id: I4b5755a63d9454db20f63f751f5f33564a2ee5be
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
error:
|
||||
… while evaluating a path segment
|
||||
at /pwd/in.nix:1:2:
|
||||
1| "${x: x}"
|
||||
| ^
|
||||
2|
|
||||
|
||||
error: cannot coerce a function to a string: «lambda @ /pwd/in.nix:1:4»
|
||||
@@ -0,0 +1 @@
|
||||
error: getting status of '/pwd/fnord': No such file or directory
|
||||
@@ -0,0 +1,8 @@
|
||||
error:
|
||||
… while evaluating a path segment
|
||||
at /pwd/in.nix:1:3:
|
||||
1| ''${x: x}''
|
||||
| ^
|
||||
2|
|
||||
|
||||
error: cannot coerce a function to a string: «lambda @ /pwd/in.nix:1:5»
|
||||
@@ -0,0 +1,9 @@
|
||||
error:
|
||||
… while evaluating a path segment
|
||||
at /pwd/in.nix:9:3:
|
||||
8| # The error message should not be too long.
|
||||
9| ''${pkgs}''
|
||||
| ^
|
||||
10|
|
||||
|
||||
error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» }
|
||||
@@ -0,0 +1 @@
|
||||
"${x: x}"
|
||||
@@ -0,0 +1 @@
|
||||
"${./fnord}"
|
||||
@@ -0,0 +1 @@
|
||||
''${x: x}''
|
||||
@@ -0,0 +1,9 @@
|
||||
let
|
||||
# Basically a "billion laughs" attack, but toned down to simulated `pkgs`.
|
||||
ha = x: y: { a = x y; b = x y; c = x y; d = x y; e = x y; f = x y; g = x y; h = x y; j = x y; };
|
||||
has = ha (ha (ha (ha (x: x)))) "ha";
|
||||
# A large structure that has already been evaluated.
|
||||
pkgs = builtins.deepSeq has has;
|
||||
in
|
||||
# The error message should not be too long.
|
||||
''${pkgs}''
|
||||
@@ -0,0 +1,10 @@
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
def test_err_context(nix: Nix):
|
||||
# the lang test framework doesn't check this folder, as there is a custom test in here
|
||||
# it won't scream about missing an `in.nix` or .exp files
|
||||
result = nix.nix_instantiate(
|
||||
["--show-trace", "--eval", "-E", 'builtins.addErrorContext "Hello" (throw "Foo")']
|
||||
).run()
|
||||
assert "Hello" in result.expect(1).stderr_s
|
||||
@@ -0,0 +1 @@
|
||||
[ 1 2 3 4 5 6 7 8 9 10 ]
|
||||
@@ -0,0 +1,3 @@
|
||||
# The function ‘range’ comes from lib.nix and was added to the lexical
|
||||
# scope by scopedImport.
|
||||
range 1 5 ++ import ./imported2.nix
|
||||
@@ -0,0 +1 @@
|
||||
range 6 10
|
||||
@@ -0,0 +1,11 @@
|
||||
let
|
||||
|
||||
overrides = {
|
||||
import = fn: scopedImport overrides fn;
|
||||
|
||||
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
|
||||
|
||||
builtins = builtins // overrides;
|
||||
} // import ./lib.nix;
|
||||
|
||||
in scopedImport overrides ./imported.nix
|
||||
@@ -0,0 +1,3 @@
|
||||
[eval-okay]
|
||||
runner = "eval-okay"
|
||||
extra-files = ["imported.nix", "imported2.nix"]
|
||||
@@ -0,0 +1,18 @@
|
||||
_type: ExprSet
|
||||
attrs:
|
||||
foo:
|
||||
_type: ExprLiteral
|
||||
value: "multi\nline\n string\n test\r"
|
||||
valueType: String
|
||||
x:
|
||||
_type: ExprVar
|
||||
value: y
|
||||
y:
|
||||
_type: ExprLiteral
|
||||
value: 123
|
||||
valueType: Int
|
||||
z:
|
||||
_type: ExprLiteral
|
||||
value: 456
|
||||
valueType: Int
|
||||
recursive: true
|
||||
@@ -0,0 +1,12 @@
|
||||
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 /pwd/in.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 /pwd/in.nix:14:15:
|
||||
13| # translated to LF.
|
||||
14| foo = "multi
|
||||
| ^
|
||||
15| line
|
||||
@@ -0,0 +1,17 @@
|
||||
rec {
|
||||
|
||||
/* Dit is
|
||||
een test. */
|
||||
|
||||
x =
|
||||
# Dit is een test.
|
||||
y;
|
||||
|
||||
y = 123;
|
||||
|
||||
# CR or CR/LF (but not explicit \r's) in strings should be
|
||||
# translated to LF.
|
||||
foo = "multi
|
||||
line
|
||||
string
|
||||
test\r";
|
||||
@@ -0,0 +1,6 @@
|
||||
[depr]
|
||||
runner = "parse-fail"
|
||||
|
||||
[allow-depr]
|
||||
runner = "parse-okay"
|
||||
flags = ["--extra-deprecated-features", "cr-line-endings"]
|
||||
@@ -0,0 +1 @@
|
||||
"foo"
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
_type: ExprLiteral
|
||||
value: foo
|
||||
valueType: String
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
[eval-depr]
|
||||
runner = "eval-fail"
|
||||
|
||||
[eval-allow-depr]
|
||||
runner = "eval-okay"
|
||||
flags = ["--extra-deprecated-features", "nul-bytes"]
|
||||
|
||||
[parse-depr]
|
||||
runner = "parse-fail"
|
||||
|
||||
[parse-allow-depr]
|
||||
runner = "parse-okay"
|
||||
flags = ["--extra-deprecated-features", "nul-bytes"]
|
||||
@@ -0,0 +1,35 @@
|
||||
error:
|
||||
… from call site
|
||||
at /pwd/in.nix:7:3:
|
||||
6| in
|
||||
7| f {}
|
||||
| ^
|
||||
8|
|
||||
|
||||
… while calling 'f'
|
||||
at /pwd/in.nix:5:7:
|
||||
4|
|
||||
5| f = {x ? y, y ? x}: x + y;
|
||||
| ^
|
||||
6| in
|
||||
|
||||
… while evaluating x
|
||||
at /pwd/in.nix:5:23:
|
||||
4|
|
||||
5| f = {x ? y, y ? x}: x + y;
|
||||
| ^
|
||||
6| in
|
||||
|
||||
… while evaluating y
|
||||
at /pwd/in.nix:5:12:
|
||||
4|
|
||||
5| f = {x ? y, y ? x}: x + y;
|
||||
| ^
|
||||
6| in
|
||||
|
||||
error: infinite recursion encountered
|
||||
at /pwd/in.nix:5:12:
|
||||
4|
|
||||
5| f = {x ? y, y ? x}: x + y;
|
||||
| ^
|
||||
6| in
|
||||
@@ -0,0 +1 @@
|
||||
3
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
4
|
||||
@@ -0,0 +1 @@
|
||||
"ccdd"
|
||||
@@ -0,0 +1 @@
|
||||
"ccdd"
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
(({x}: x:
|
||||
|
||||
{ x = 1;
|
||||
y = x;
|
||||
}
|
||||
) {x = 2;} 3).y
|
||||
@@ -0,0 +1,6 @@
|
||||
((x: {x}:
|
||||
rec {
|
||||
x = 1;
|
||||
y = x;
|
||||
}
|
||||
) 2 {x = 3;}).y
|
||||
@@ -0,0 +1,6 @@
|
||||
((x: as: {x}:
|
||||
rec {
|
||||
inherit (as) x;
|
||||
y = x;
|
||||
}
|
||||
) 2 {x = 4;} {x = 3;}).y
|
||||
@@ -0,0 +1,7 @@
|
||||
let
|
||||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
in
|
||||
f {x = "c";} + f {y = "d";}
|
||||
@@ -0,0 +1,7 @@
|
||||
let
|
||||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
in
|
||||
f {}
|
||||
@@ -0,0 +1,5 @@
|
||||
let
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
in
|
||||
f {x = "c";} + f {y = "d";}
|
||||
@@ -0,0 +1,6 @@
|
||||
rec {
|
||||
inherit (x) y;
|
||||
x = {
|
||||
y = 1;
|
||||
};
|
||||
}.y
|
||||
@@ -0,0 +1 @@
|
||||
"xyzzybarxyzzybar"
|
||||
@@ -0,0 +1,19 @@
|
||||
let
|
||||
|
||||
a = "xyzzy";
|
||||
|
||||
as = {
|
||||
a = "foo";
|
||||
b = "bar";
|
||||
};
|
||||
|
||||
bs = {
|
||||
a = "bar";
|
||||
};
|
||||
|
||||
x = with as; a + b;
|
||||
|
||||
y = with as; with bs; a + b;
|
||||
|
||||
in
|
||||
x + y
|
||||
Reference in New Issue
Block a user