test(tvix/eval): update nix_tests suite to C++ Nix master
Adds new tests for foldl', intersectAttrs as well as fills in missing .exp files. New test cases we don't pass: - fromTOML timestamp capabilities - path antiquotation - replaceStrings is lazier on C++ Nix master The C++ Nix revision used is 7066d21a0ddb421967980094222c4bc1f5a0f45a. Change-Id: Ic619c96e2d41e6c5ea6fa93f9402b12e564af3c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8778 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
9278a0cd16
commit
3b8c9ec9c8
27 changed files with 396 additions and 7 deletions
|
@ -0,0 +1,5 @@
|
|||
# Tests that the result of applying op is forced even if the value is never used
|
||||
builtins.foldl'
|
||||
(_: f: f null)
|
||||
null
|
||||
[ (_: throw "Not the final value, but is still forced!") (_: 23) ]
|
|
@ -0,0 +1 @@
|
|||
42
|
|
@ -0,0 +1,9 @@
|
|||
# Tests that the rhs argument of op is not forced unconditionally
|
||||
let
|
||||
lst = builtins.foldl'
|
||||
(acc: x: acc ++ [ x ])
|
||||
[ ]
|
||||
[ 42 (throw "this shouldn't be evaluated") ];
|
||||
in
|
||||
|
||||
builtins.head lst
|
|
@ -0,0 +1 @@
|
|||
42
|
|
@ -0,0 +1,6 @@
|
|||
# Checks that the nul value for the accumulator is not forced unconditionally.
|
||||
# Some languages provide a foldl' that is strict in this argument, but Nix does not.
|
||||
builtins.foldl'
|
||||
(_: x: x)
|
||||
(throw "This is never forced")
|
||||
[ "but the results of applying op are" 42 ]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-functionargs.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-functionargs.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ "stdenv" "fetchurl" "aterm-stdenv" "aterm-stdenv2" "libX11" "libXv" "mplayer-stdenv2.libXv-libX11" "mplayer-stdenv2.libXv-libX11_2" "nix-stdenv-aterm-stdenv" "nix-stdenv2-aterm2-stdenv2" ]
|
|
@ -110,7 +110,7 @@ let
|
|||
And finally to interpret \n etc. as in a string: ''\n, ''\r, ''\t.
|
||||
'';
|
||||
|
||||
# Regression test: antiquotation in '${x}' should work, but didn't.
|
||||
# Regression test: string interpolation in '${x}' should work, but didn't.
|
||||
s15 = let x = "bla"; in ''
|
||||
foo
|
||||
'${x}'
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[ { } { a = 1; } { a = 1; } { a = "a"; } { m = 1; } { m = "m"; } { n = 1; } { n = "n"; } { n = 1; p = 2; } { n = "n"; p = "p"; } { n = 1; p = 2; } { n = "n"; p = "p"; } { a = "a"; b = "b"; c = "c"; d = "d"; e = "e"; f = "f"; g = "g"; h = "h"; i = "i"; j = "j"; k = "k"; l = "l"; m = "m"; n = "n"; o = "o"; p = "p"; q = "q"; r = "r"; s = "s"; t = "t"; u = "u"; v = "v"; w = "w"; x = "x"; y = "y"; z = "z"; } true ]
|
50
tvix/eval/src/tests/nix_tests/eval-okay-intersectAttrs.nix
Normal file
50
tvix/eval/src/tests/nix_tests/eval-okay-intersectAttrs.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
let
|
||||
alphabet =
|
||||
{ a = "a";
|
||||
b = "b";
|
||||
c = "c";
|
||||
d = "d";
|
||||
e = "e";
|
||||
f = "f";
|
||||
g = "g";
|
||||
h = "h";
|
||||
i = "i";
|
||||
j = "j";
|
||||
k = "k";
|
||||
l = "l";
|
||||
m = "m";
|
||||
n = "n";
|
||||
o = "o";
|
||||
p = "p";
|
||||
q = "q";
|
||||
r = "r";
|
||||
s = "s";
|
||||
t = "t";
|
||||
u = "u";
|
||||
v = "v";
|
||||
w = "w";
|
||||
x = "x";
|
||||
y = "y";
|
||||
z = "z";
|
||||
};
|
||||
foo = {
|
||||
inherit (alphabet) f o b a r z q u x;
|
||||
aa = throw "aa";
|
||||
};
|
||||
alphabetFail = builtins.mapAttrs throw alphabet;
|
||||
in
|
||||
[ (builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; })
|
||||
(builtins.intersectAttrs { a = abort "l2"; } { a = 1; })
|
||||
(builtins.intersectAttrs alphabetFail { a = 1; })
|
||||
(builtins.intersectAttrs { a = abort "laa"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { m = 1; })
|
||||
(builtins.intersectAttrs { m = abort "lam"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; })
|
||||
(builtins.intersectAttrs { n = abort "lan"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail alphabet)
|
||||
(builtins.intersectAttrs alphabet foo == builtins.intersectAttrs foo alphabet)
|
||||
]
|
1
tvix/eval/src/tests/nix_tests/eval-okay-path.exp
Normal file
1
tvix/eval/src/tests/nix_tests/eval-okay-path.exp
Normal file
|
@ -0,0 +1 @@
|
|||
"/nix/store/ya937r4ydw0l6kayq8jkyqaips9c75jm-output"
|
|
@ -1 +0,0 @@
|
|||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" ]
|
|
@ -0,0 +1,130 @@
|
|||
builtins.fromTOML ''
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
bare-key = "value"
|
||||
1234 = "value"
|
||||
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
"ʎǝʞ" = "value"
|
||||
'key2' = "value"
|
||||
'quoted "value"' = "value"
|
||||
|
||||
name = "Orange"
|
||||
|
||||
physical.color = "orange"
|
||||
physical.shape = "round"
|
||||
site."google.com" = true
|
||||
|
||||
# This is legal according to the spec, but cpptoml doesn't handle it.
|
||||
#a.b.c = 1
|
||||
#a.d = 2
|
||||
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
int3 = 0
|
||||
int4 = -17
|
||||
int5 = 1_000
|
||||
int6 = 5_349_221
|
||||
int7 = 1_2_3_4_5
|
||||
|
||||
hex1 = 0xDEADBEEF
|
||||
hex2 = 0xdeadbeef
|
||||
hex3 = 0xdead_beef
|
||||
|
||||
oct1 = 0o01234567
|
||||
oct2 = 0o755
|
||||
|
||||
bin1 = 0b11010110
|
||||
|
||||
flt1 = +1.0
|
||||
flt2 = 3.1415
|
||||
flt3 = -0.01
|
||||
flt4 = 5e+22
|
||||
flt5 = 1e6
|
||||
flt6 = -2E-2
|
||||
flt7 = 6.626e-34
|
||||
flt8 = 9_224_617.445_991_228_313
|
||||
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
|
||||
odt1 = 1979-05-27T07:32:00Z
|
||||
odt2 = 1979-05-27T00:32:00-07:00
|
||||
odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||
odt4 = 1979-05-27 07:32:00Z
|
||||
ldt1 = 1979-05-27T07:32:00
|
||||
ldt2 = 1979-05-27T00:32:00.999999
|
||||
ld1 = 1979-05-27
|
||||
lt1 = 07:32:00
|
||||
lt2 = 00:32:00.999999
|
||||
|
||||
arr1 = [ 1, 2, 3 ]
|
||||
arr2 = [ "red", "yellow", "green" ]
|
||||
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
|
||||
arr4 = [ "all", 'strings', """are the same""", ''''type'''']
|
||||
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
|
||||
|
||||
arr7 = [
|
||||
1, 2, 3
|
||||
]
|
||||
|
||||
arr8 = [
|
||||
1,
|
||||
2, # this is ok
|
||||
]
|
||||
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
key2 = 123
|
||||
|
||||
|
||||
[table-2]
|
||||
key1 = "another string"
|
||||
key2 = 456
|
||||
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
|
||||
[a.b.c]
|
||||
[ d.e.f ]
|
||||
[ g . h . i ]
|
||||
[ j . "ʞ" . 'l' ]
|
||||
[x.y.z.w]
|
||||
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
''
|
|
@ -1 +1 @@
|
|||
true
|
||||
[ true true true true true true ]
|
||||
|
|
|
@ -18,7 +18,24 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||
combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||
legit-context = builtins.getContext combo-path;
|
||||
|
||||
constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
|
||||
in legit-context == constructed-context
|
||||
reconstructed-path = builtins.appendContext
|
||||
(builtins.unsafeDiscardStringContext combo-path)
|
||||
desired-context;
|
||||
|
||||
# Eta rule for strings with context.
|
||||
etaRule = str:
|
||||
str == builtins.appendContext
|
||||
(builtins.unsafeDiscardStringContext str)
|
||||
(builtins.getContext str);
|
||||
|
||||
in [
|
||||
(legit-context == desired-context)
|
||||
(reconstructed-path == combo-path)
|
||||
(etaRule "foo")
|
||||
(etaRule drv.drvPath)
|
||||
(etaRule drv.foo.outPath)
|
||||
(etaRule (builtins.unsafeDiscardOutputDependency drv.drvPath))
|
||||
]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{ "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; ld1 = { _type = "timestamp"; value = "1979-05-27"; }; ldt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00"; }; ldt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999"; }; lt1 = { _type = "timestamp"; value = "07:32:00"; }; lt2 = { _type = "timestamp"; value = "00:32:00.999999"; }; name = "Orange"; oct1 = 342391; oct2 = 493; odt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00-07:00"; }; odt3 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999-07:00"; }; odt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; }
|
|
@ -0,0 +1 @@
|
|||
--extra-experimental-features parse-toml-timestamps
|
|
@ -0,0 +1,130 @@
|
|||
builtins.fromTOML ''
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
bare-key = "value"
|
||||
1234 = "value"
|
||||
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
"ʎǝʞ" = "value"
|
||||
'key2' = "value"
|
||||
'quoted "value"' = "value"
|
||||
|
||||
name = "Orange"
|
||||
|
||||
physical.color = "orange"
|
||||
physical.shape = "round"
|
||||
site."google.com" = true
|
||||
|
||||
# This is legal according to the spec, but cpptoml doesn't handle it.
|
||||
#a.b.c = 1
|
||||
#a.d = 2
|
||||
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
int3 = 0
|
||||
int4 = -17
|
||||
int5 = 1_000
|
||||
int6 = 5_349_221
|
||||
int7 = 1_2_3_4_5
|
||||
|
||||
hex1 = 0xDEADBEEF
|
||||
hex2 = 0xdeadbeef
|
||||
hex3 = 0xdead_beef
|
||||
|
||||
oct1 = 0o01234567
|
||||
oct2 = 0o755
|
||||
|
||||
bin1 = 0b11010110
|
||||
|
||||
flt1 = +1.0
|
||||
flt2 = 3.1415
|
||||
flt3 = -0.01
|
||||
flt4 = 5e+22
|
||||
flt5 = 1e6
|
||||
flt6 = -2E-2
|
||||
flt7 = 6.626e-34
|
||||
flt8 = 9_224_617.445_991_228_313
|
||||
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
|
||||
odt1 = 1979-05-27T07:32:00Z
|
||||
odt2 = 1979-05-27T00:32:00-07:00
|
||||
odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||
odt4 = 1979-05-27 07:32:00Z
|
||||
ldt1 = 1979-05-27T07:32:00
|
||||
ldt2 = 1979-05-27T00:32:00.999999
|
||||
ld1 = 1979-05-27
|
||||
lt1 = 07:32:00
|
||||
lt2 = 00:32:00.999999
|
||||
|
||||
arr1 = [ 1, 2, 3 ]
|
||||
arr2 = [ "red", "yellow", "green" ]
|
||||
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
|
||||
arr4 = [ "all", 'strings', """are the same""", ''''type'''']
|
||||
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
|
||||
|
||||
arr7 = [
|
||||
1, 2, 3
|
||||
]
|
||||
|
||||
arr8 = [
|
||||
1,
|
||||
2, # this is ok
|
||||
]
|
||||
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
key2 = 123
|
||||
|
||||
|
||||
[table-2]
|
||||
key1 = "another string"
|
||||
key2 = 456
|
||||
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
|
||||
[a.b.c]
|
||||
[ d.e.f ]
|
||||
[ g . h . i ]
|
||||
[ j . "ʞ" . 'l' ]
|
||||
[x.y.z.w]
|
||||
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
''
|
|
@ -0,0 +1 @@
|
|||
{ absolute = /foo; expr = /pwd/lang/foo/bar; home = /fake-home/foo; notfirst = /pwd/lang/bar/foo; simple = /pwd/lang/foo; slashes = /foo/bar; surrounded = /pwd/lang/a-foo-b; }
|
|
@ -0,0 +1,12 @@
|
|||
let
|
||||
foo = "foo";
|
||||
in
|
||||
{
|
||||
simple = ./${foo};
|
||||
surrounded = ./a-${foo}-b;
|
||||
absolute = /${foo};
|
||||
expr = ./${foo + "/bar"};
|
||||
home = ~/${foo};
|
||||
notfirst = ./bar/${foo};
|
||||
slashes = /${foo}/${"bar"};
|
||||
}
|
|
@ -1 +1 @@
|
|||
{ bar = "regular"; foo = "directory"; }
|
||||
{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; }
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; }
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
bar = builtins.readFileType ./readDir/bar;
|
||||
foo = builtins.readFileType ./readDir/foo;
|
||||
linked = builtins.readFileType ./readDir/linked;
|
||||
ldir = builtins.readFileType ./readDir/ldir;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" "fubar" ]
|
|
@ -8,4 +8,5 @@ with builtins;
|
|||
(replaceStrings [""] ["X"] "abc")
|
||||
(replaceStrings [""] ["X"] "")
|
||||
(replaceStrings ["-"] ["_"] "a-b")
|
||||
(replaceStrings ["oo" "XX"] ["u" (throw "unreachable")] "foobar")
|
||||
]
|
1
tvix/eval/src/tests/nix_tests/notyetpassing/readDir/ldir
Symbolic link
1
tvix/eval/src/tests/nix_tests/notyetpassing/readDir/ldir
Symbolic link
|
@ -0,0 +1 @@
|
|||
foo
|
1
tvix/eval/src/tests/nix_tests/notyetpassing/readDir/linked
Symbolic link
1
tvix/eval/src/tests/nix_tests/notyetpassing/readDir/linked
Symbolic link
|
@ -0,0 +1 @@
|
|||
foo/git-hates-directories
|
|
@ -36,6 +36,8 @@ let
|
|||
]
|
||||
) [ "nix_tests" "nix_tests/notyetpassing" "tvix_tests" "tvix_tests/notyetpassing" ];
|
||||
|
||||
latestNixIs215 = lib.versionOlder nix_latest.version "2.16";
|
||||
|
||||
skippedLangTests = {
|
||||
# TODO(sterni): set up NIX_PATH in sandbox
|
||||
"eval-okay-search-path.nix" = true;
|
||||
|
@ -64,6 +66,16 @@ let
|
|||
"eval-okay-import-display.nix" = [ nix ];
|
||||
# Cycle detection and formatting changed sometime after Nix 2.3
|
||||
"eval-okay-cycle-display-cpp-nix-2.13.nix" = [ nix ];
|
||||
# builtins.replaceStrings becomes lazier in Nix 2.16
|
||||
"eval-okay-replacestrings.nix" = [ nix (assert latestNixIs215; nix_latest) ];
|
||||
# builtins.readFileType is added in Nix 2.15
|
||||
"eval-okay-readFileType.nix" = [ nix ];
|
||||
# builtins.fromTOML gains support for timestamps in Nix 2.16
|
||||
"eval-okay-fromTOML-timestamps.nix" = [ nix (assert latestNixIs215; nix_latest) ];
|
||||
|
||||
# TODO(sterni): support diffing working directory and home relative paths
|
||||
# like C++ Nix test suite (using string replacement).
|
||||
"eval-okay-path-antiquotation.nix" = true;
|
||||
};
|
||||
|
||||
runCppNixLangTests = cpp-nix:
|
||||
|
|
Loading…
Reference in a new issue