about summary refs log tree commit diff
path: root/tvix/eval/src/tests
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2022-10-13T02·47-0400
committergrfn <grfn@gws.fyi>2022-10-22T18·11+0000
commitd4fa3152e92ef72d9ee050000b1fd4952203e383 (patch)
tree288cd7bd6f47169aec08e402edd0cf5fb90560fa /tvix/eval/src/tests
parent8724d2fff871827dc66503f9b3dfa1d29149ddc7 (diff)
feat(tvix/eval): Implement builtins.deepSeq r/5175
This is done via a new `deepForce` function on Value. Since values can
be cyclical (for example, see the test-case), we need to do some extra
work to avoid RefCell borrow errors if we ever hit a graph cycle:

While deep-forcing values, we keep a set of thunks that we have
already seen and avoid doing any work on the same thunk twice. The set
is encapsulated in a separate type to stop potentially invalid
pointers from leaking out.

Finally, since deep_force is conceptually similar to
`VM::force_for_output` (but more suited to usage in eval since it
doesn't clone the values) this removes the latter, replacing it with
the former.

Co-Authored-By: Vincent Ambo <tazjin@tvl.su>
Change-Id: Iefddefcf09fae3b6a4d161a5873febcff54b9157
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7000
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/tests')
-rw-r--r--tvix/eval/src/tests/nix_tests/eval-okay-deepseq.exp (renamed from tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.exp)0
-rw-r--r--tvix/eval/src/tests/nix_tests/eval-okay-deepseq.nix (renamed from tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.nix)0
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-fail-deepseq.nix1
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.exp1
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.nix1
5 files changed, 3 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.exp b/tvix/eval/src/tests/nix_tests/eval-okay-deepseq.exp
index 8d38505c16..8d38505c16 100644
--- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.exp
+++ b/tvix/eval/src/tests/nix_tests/eval-okay-deepseq.exp
diff --git a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.nix b/tvix/eval/src/tests/nix_tests/eval-okay-deepseq.nix
index 53aa4b1dc2..53aa4b1dc2 100644
--- a/tvix/eval/src/tests/nix_tests/notyetpassing/eval-okay-deepseq.nix
+++ b/tvix/eval/src/tests/nix_tests/eval-okay-deepseq.nix
diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-deepseq.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-deepseq.nix
new file mode 100644
index 0000000000..9baa49b063
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-fail-deepseq.nix
@@ -0,0 +1 @@
+builtins.deepSeq { x = abort "foo"; } 456
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.exp
new file mode 100644
index 0000000000..8d38505c16
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.exp
@@ -0,0 +1 @@
+456
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.nix
new file mode 100644
index 0000000000..53aa4b1dc2
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-deepseq.nix
@@ -0,0 +1 @@
+builtins.deepSeq (let as = { x = 123; y = as; }; in as) 456