From dfd0066de5f0616673f8e6cef4c6bed312e98d1e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 4 Mar 2023 00:06:00 +0300 Subject: fix(tvix/eval): handle toJSON on attribute sets with `outPath` These are serialised as the serialisation of the value of that field. Change-Id: Ida51708b1f43ce09b0ec835f4e265918aa31dd09 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8205 Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- .../tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.exp | 1 + .../tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.nix | 8 ++++++++ .../src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.exp | 1 + .../src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.nix | 5 +++++ 4 files changed, 15 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.nix create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.nix (limited to 'tvix/eval/src/tests/tvix_tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.exp new file mode 100644 index 0000000000..69667de5a1 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.exp @@ -0,0 +1 @@ +"{\"a\":40,\"b\":2}" diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.nix new file mode 100644 index 0000000000..70755c8c6d --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath-nested.nix @@ -0,0 +1,8 @@ +# Attribute sets with an `outPath` can contain _any_ serialisable +# value in that field. +builtins.toJSON { + outPath = { + a = 40; + b = 2; + }; +} diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.exp new file mode 100644 index 0000000000..82dd081798 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.exp @@ -0,0 +1 @@ +"\"/nix/store/jzka5ndnygkkfjfvpqwjipqp75lhz138-emacs-28.2\"" diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.nix new file mode 100644 index 0000000000..7f9d95ac60 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-outpath.nix @@ -0,0 +1,5 @@ +# Attribute sets with an `outPath` have that outPath itself serialised +# to string. +builtins.toJSON { + outPath = "/nix/store/jzka5ndnygkkfjfvpqwjipqp75lhz138-emacs-28.2"; +} -- cgit 1.4.1