From 8e188d623591871944c5d8626921747333454e9e Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 19 Oct 2022 16:36:28 +0200 Subject: [PATCH] test(tvix/eval): update C++ Nix test suite to current master The language test suite actually doesn't require flakes and the new features are mostly sensible (added builtins) as well as some tests for regressions the C++ implementation experienced. The path interpolation test is not included in this update because there is no way to construct an location-independent .exp file for it (the C++ repo also doesn't have one). We may still want to implement that feature eventually (in case rnix adds support for it). The C++ Nix revision used is ac0fb38e8a5a25a84fa17704bd31b453211263eb. Change-Id: I75f1e780ddeeee6f6b1f28cf3c66c288dca2c20c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7043 Autosubmit: sterni Tested-by: BuildkiteCI Reviewed-by: tazjin --- .../tests/nix_tests/eval-okay-foldlStrict.exp | 1 + .../tests/nix_tests/eval-okay-foldlStrict.nix | 3 ++ .../eval-okay-regression-20220122.exp | 1 + .../eval-okay-regression-20220122.nix | 1 + .../eval-okay-regression-20220125.exp | 1 + .../eval-okay-regression-20220125.nix | 2 + ...d-path.nix => eval-fail-nonexist-path.nix} | 0 .../notyetpassing/eval-okay-floor-ceil.exp | 1 + .../notyetpassing/eval-okay-floor-ceil.nix | 9 ++++ .../notyetpassing/eval-okay-fromjson.nix | 49 +++++++++---------- .../eval-okay-getattrpos-functionargs.exp | 1 + .../eval-okay-getattrpos-functionargs.nix | 4 ++ .../notyetpassing/eval-okay-groupBy.exp | 1 + .../notyetpassing/eval-okay-groupBy.nix | 5 ++ .../notyetpassing/eval-okay-search-path.nix | 5 +- .../notyetpassing/eval-okay-sort.exp | 2 +- .../notyetpassing/eval-okay-sort.nix | 14 +++++- .../nix_tests/notyetpassing/eval-okay-xml.exp | 2 +- .../notyetpassing/eval-okay-zipAttrsWith.exp | 1 + .../notyetpassing/eval-okay-zipAttrsWith.nix | 9 ++++ .../nix_tests/parse-fail-eof-in-string.nix | 3 ++ .../src/tests/nix_tests/parse-okay-url.nix | 1 + tvix/verify-lang-tests/default.nix | 10 +++- 23 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.exp create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.nix create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.exp create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.nix create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.exp create mode 100644 tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.nix rename tvix/eval/src/tests/nix_tests/notyetpassing/{eval-fail-antiquoted-path.nix => eval-fail-nonexist-path.nix} (100%) create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.exp create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.nix create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.exp create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.nix create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.exp create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.nix create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.exp create mode 100644 tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.nix create mode 100644 tvix/eval/src/tests/nix_tests/parse-fail-eof-in-string.nix diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.exp b/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.exp new file mode 100644 index 000000000..837e12b40 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.exp @@ -0,0 +1 @@ +500500 diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.nix b/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.nix new file mode 100644 index 000000000..3b87188d2 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-foldlStrict.nix @@ -0,0 +1,3 @@ +with import ./lib.nix; + +builtins.foldl' (x: y: x + y) 0 (range 1 1000) diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.exp b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.exp new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.exp @@ -0,0 +1 @@ +3 diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.nix b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.nix new file mode 100644 index 000000000..694e9a13b --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220122.nix @@ -0,0 +1 @@ +((_: _) 1) + ((__: __) 2) diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.exp b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.exp new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.exp @@ -0,0 +1 @@ +3 diff --git a/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.nix b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.nix new file mode 100644 index 000000000..485502373 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/eval-okay-regression-20220125.nix @@ -0,0 +1,2 @@ +((__curPosFoo: __curPosFoo) 1) + ((__curPosBar: __curPosBar) 2) + diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-fail-antiquoted-path.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-fail-nonexist-path.nix similarity index 100% rename from tvix/eval/src/tests/nix_tests/notyetpassing/eval-fail-antiquoted-path.nix rename to tvix/eval/src/tests/nix_tests/notyetpassing/eval-fail-nonexist-path.nix diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.exp new file mode 100644 index 000000000..81f80420b --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.exp @@ -0,0 +1 @@ +"23;24;23;23" diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.nix new file mode 100644 index 000000000..d76a0d86e --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-floor-ceil.nix @@ -0,0 +1,9 @@ +with import ./lib.nix; + +let + n1 = builtins.floor 23.5; + n2 = builtins.ceil 23.5; + n3 = builtins.floor 23; + n4 = builtins.ceil 23; +in + builtins.concatStringsSep ";" (map toString [ n1 n2 n3 n4 ]) diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-fromjson.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-fromjson.nix index 102ee82b5..e1c0f86cc 100644 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-fromjson.nix +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-fromjson.nix @@ -1,36 +1,35 @@ -# RFC 7159, section 13. builtins.fromJSON '' { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 + "Video": { + "Title": "The Penguin Chronicles", + "Width": 1920, + "Height": 1080, + "EmbeddedData": [3.14159, 23493,null, true ,false, -10], + "Thumb": { + "Url": "http://www.example.com/video/5678931", + "Width": 200, + "Height": 250 }, - "Animated" : false, - "IDs": [116, 943, 234, 38793, true ,false,null, -100], - "Latitude": 37.7668, - "Longitude": -122.3959 + "Subtitle" : false, + "Latitude": 46.2051, + "Longitude": 6.0723 } } '' == - { Image = - { Width = 800; - Height = 600; - Title = "View from 15th Floor"; - Thumbnail = - { Url = http://www.example.com/image/481989943; - Height = 125; - Width = 100; + { Video = + { Title = "The Penguin Chronicles"; + Width = 1920; + Height = 1080; + EmbeddedData = [ 3.14159 23493 null true false (0-10) ]; + Thumb = + { Url = "http://www.example.com/video/5678931"; + Width = 200; + Height = 250; }; - Animated = false; - IDs = [ 116 943 234 38793 true false null (0-100) ]; - Latitude = 37.7668; - Longitude = -122.3959; + Subtitle = false; + Latitude = 46.2051; + Longitude = 6.0723; }; } diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.exp new file mode 100644 index 000000000..7f9ac40e8 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.exp @@ -0,0 +1 @@ +{ column = 11; file = "eval-okay-getattrpos-functionargs.nix"; line = 2; } diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.nix new file mode 100644 index 000000000..11d6bb0e3 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-getattrpos-functionargs.nix @@ -0,0 +1,4 @@ +let + fun = { foo }: {}; + pos = builtins.unsafeGetAttrPos "foo" (builtins.functionArgs fun); +in { inherit (pos) column line; file = baseNameOf pos.file; } diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.exp new file mode 100644 index 000000000..bfca5652a --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.exp @@ -0,0 +1 @@ +{ "1" = [ 9 ]; "2" = [ 8 ]; "3" = [ 13 29 ]; "4" = [ 3 4 10 11 17 18 ]; "5" = [ 0 23 26 28 ]; "6" = [ 1 12 21 27 30 ]; "7" = [ 7 22 ]; "8" = [ 14 ]; "9" = [ 19 ]; b = [ 16 25 ]; c = [ 24 ]; d = [ 2 ]; e = [ 5 6 15 31 ]; f = [ 20 ]; } diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.nix new file mode 100644 index 000000000..7e0eab28b --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-groupBy.nix @@ -0,0 +1,5 @@ +with import ./../lib.nix; + +builtins.groupBy (n: + builtins.substring 0 1 (builtins.hashString "sha256" (toString n)) +) (range 0 31) diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-search-path.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-search-path.nix index cca41f821..6fe33decc 100644 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-search-path.nix +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-search-path.nix @@ -1,10 +1,9 @@ with import ./lib.nix; with builtins; -assert pathExists ; +assert isFunction (import ); -assert length __nixPath == 6; -assert length (filter (x: x.prefix == "nix") __nixPath) == 1; +assert length __nixPath == 5; assert length (filter (x: baseNameOf x.path == "dir4") __nixPath) == 1; import + import + import + import diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp index 148b93516..899119e20 100644 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.exp @@ -1 +1 @@ -[ [ 42 77 147 249 483 526 ] [ 526 483 249 147 77 42 ] [ "bar" "fnord" "foo" "xyzzy" ] [ { key = 1; value = "foo"; } { key = 1; value = "fnord"; } { key = 2; value = "bar"; } ] ] +[ [ 42 77 147 249 483 526 ] [ 526 483 249 147 77 42 ] [ "bar" "fnord" "foo" "xyzzy" ] [ { key = 1; value = "foo"; } { key = 1; value = "fnord"; } { key = 2; value = "bar"; } ] [ [ ] [ ] [ 1 ] [ 1 4 ] [ 1 5 ] [ 1 6 ] [ 2 ] [ 2 3 ] [ 3 ] [ 3 ] ] ] diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix index 8299c3a4a..50aa78e40 100644 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-sort.nix @@ -4,5 +4,17 @@ with builtins; (sort (x: y: y < x) [ 483 249 526 147 42 77 ]) (sort lessThan [ "foo" "bar" "xyzzy" "fnord" ]) (sort (x: y: x.key < y.key) - [ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ]) + [ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ]) + (sort lessThan [ + [ 1 6 ] + [ ] + [ 2 3 ] + [ 3 ] + [ 1 5 ] + [ 2 ] + [ 1 ] + [ ] + [ 1 4 ] + [ 3 ] + ]) ] diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-xml.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-xml.exp index 92b75e0b8..20099326c 100644 --- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-xml.exp +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-xml.exp @@ -31,9 +31,9 @@ - + diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.exp b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.exp new file mode 100644 index 000000000..9c0b15d22 --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.exp @@ -0,0 +1 @@ +{ "0" = { n = "0"; v = [ 5 23 29 ]; }; "1" = { n = "1"; v = [ 7 30 ]; }; "2" = { n = "2"; v = [ 18 ]; }; "4" = { n = "4"; v = [ 10 ]; }; "5" = { n = "5"; v = [ 15 25 26 31 ]; }; "6" = { n = "6"; v = [ 3 14 ]; }; "7" = { n = "7"; v = [ 12 ]; }; "8" = { n = "8"; v = [ 2 6 8 9 ]; }; "9" = { n = "9"; v = [ 0 16 ]; }; a = { n = "a"; v = [ 17 21 22 27 ]; }; c = { n = "c"; v = [ 11 24 ]; }; d = { n = "d"; v = [ 4 13 28 ]; }; e = { n = "e"; v = [ 20 ]; }; f = { n = "f"; v = [ 1 19 ]; }; } diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.nix b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.nix new file mode 100644 index 000000000..e5d4cdccb --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-zipAttrsWith.nix @@ -0,0 +1,9 @@ +with import ./../lib.nix; + +let + str = builtins.hashString "sha256" "test"; +in +builtins.zipAttrsWith + (n: v: { inherit n v; }) + (map (n: { ${builtins.substring n 1 str} = n; }) + (range 0 31)) diff --git a/tvix/eval/src/tests/nix_tests/parse-fail-eof-in-string.nix b/tvix/eval/src/tests/nix_tests/parse-fail-eof-in-string.nix new file mode 100644 index 000000000..19775d2ec --- /dev/null +++ b/tvix/eval/src/tests/nix_tests/parse-fail-eof-in-string.nix @@ -0,0 +1,3 @@ +# https://github.com/NixOS/nix/issues/6562 +# Note that this file must not end with a newline. +a 1"$ \ No newline at end of file diff --git a/tvix/eval/src/tests/nix_tests/parse-okay-url.nix b/tvix/eval/src/tests/nix_tests/parse-okay-url.nix index fce3b13ee..08de27d0a 100644 --- a/tvix/eval/src/tests/nix_tests/parse-okay-url.nix +++ b/tvix/eval/src/tests/nix_tests/parse-okay-url.nix @@ -3,5 +3,6 @@ http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz + https://ftp5.gwdg.de/pub/linux/archlinux/extra/os/x86_64/unzip-6.0-14-x86_64.pkg.tar.zst ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz ] diff --git a/tvix/verify-lang-tests/default.nix b/tvix/verify-lang-tests/default.nix index 41282488d..2f013d6cb 100644 --- a/tvix/verify-lang-tests/default.nix +++ b/tvix/verify-lang-tests/default.nix @@ -44,7 +44,15 @@ let # C++ Nix can't do TCO "nix_tests/eval-okay-tail-call-1.nix" = true; # Ordering change after 2.3 - "nix_tests/eval-okay-xml.nix" = [ nix_latest ]; + "nix_tests/eval-okay-xml.nix" = [ nix ]; + # Missing builtins in Nix 2.3 + "nix_tests/eval-okay-floor-ceil.nix" = [ nix ]; + "nix_tests/eval-okay-groupBy.nix" = [ nix ]; + "nix_tests/eval-okay-zipAttrsWith.nix" = [ nix ]; + # Comparable lists are not in Nix 2.3 + "nix_tests/eval-okay-sort.nix" = [ nix ]; + # getAttrPos gains support for functionArgs-returned sets after 2.3 + "nix_tests/eval-okay-getattrpos-functionargs.nix" = [ nix ]; }; runCppNixLangTests = cpp-nix: