about summary refs log tree commit diff
path: root/tvix/eval/src/tests/nix_tests.rs
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-08-11T15·15-0400
committerclbot <clbot@tvl.fyi>2024-10-12T12·27+0000
commitb7a6fc2812f3ed281ba1a0b985a2ae150095f7b1 (patch)
tree8a7703be32a79fc8a6faa03385469efa24fe8be4 /tvix/eval/src/tests/nix_tests.rs
parent934e03c0deb88b3a0cff2e407e28f134c29657af (diff)
refactor(tvix/eval): Make `strict` an EvalMode enum r/8796
Refactor the `strict` boolean passed into evaluation at the top-level to
be a (two-variant, so far) EvalMode enum of Lazy and Strict.

This is more explicit than a boolean, and if we ever add more EvalModes
it's a simple extension of the enum.

Change-Id: I3de50e74ec971011664f6cd0999d08b792118410
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12186
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: aspen <root@gws.fyi>
Diffstat (limited to 'tvix/eval/src/tests/nix_tests.rs')
-rw-r--r--tvix/eval/src/tests/nix_tests.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/tvix/eval/src/tests/nix_tests.rs b/tvix/eval/src/tests/nix_tests.rs
index cdaed193f206..b17fe98bc9e4 100644
--- a/tvix/eval/src/tests/nix_tests.rs
+++ b/tvix/eval/src/tests/nix_tests.rs
@@ -37,6 +37,8 @@ mod mock_builtins {
 
 #[cfg(feature = "impure")]
 fn eval_test(code_path: PathBuf, expect_success: bool) {
+    use crate::vm::EvalMode;
+
     std::env::set_var("TEST_VAR", "foo"); // for eval-okay-getenv.nix
 
     eprintln!("path: {}", code_path.display());
@@ -49,7 +51,7 @@ fn eval_test(code_path: PathBuf, expect_success: bool) {
     let code = std::fs::read_to_string(&code_path).expect("should be able to read test code");
 
     let eval = crate::Evaluation::builder_impure()
-        .strict()
+        .mode(EvalMode::Strict)
         .add_builtins(mock_builtins::builtins())
         .build();
 
@@ -125,13 +127,13 @@ fn eval_test(code_path: PathBuf, expect_success: bool) {
 #[cfg(feature = "impure")]
 #[rstest]
 fn identity(#[files("src/tests/tvix_tests/identity-*.nix")] code_path: PathBuf) {
-    use crate::EvalIO;
+    use crate::{vm::EvalMode, EvalIO};
 
     let code = std::fs::read_to_string(code_path).expect("should be able to read test code");
 
     let eval = crate::Evaluation::builder(Box::new(crate::StdIO) as Box<dyn EvalIO>)
         .disable_import()
-        .strict()
+        .mode(EvalMode::Strict)
         .build();
 
     let result = eval.evaluate(&code, None);