From 43b9e25025eef302369ff27074bfa5bbfb1c7115 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 16 Jan 2024 15:35:44 +0200 Subject: refactor(tvix/eval): move Evaluation::{default,new_pure}() again Have a Evaluation::new() function that's used to set up the Evaluation struct initially - which is also used by both new_pure and new_impure internally. It's generic over the exact type of IO, making it easier to instantiate Evaluation with non-tvix-eval EvalIO implementations, that might not be in a Box. Change-Id: Ibf728da24aca59639c5b6df58d00ae98c99a63f5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10640 Reviewed-by: raitobezarius Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/tests/mod.rs | 7 ++----- tvix/eval/src/tests/one_offs.rs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/mod.rs b/tvix/eval/src/tests/mod.rs index e3d3445a45ac..d8b593ae9967 100644 --- a/tvix/eval/src/tests/mod.rs +++ b/tvix/eval/src/tests/mod.rs @@ -117,11 +117,8 @@ fn eval_test(code_path: PathBuf, expect_success: bool) { fn identity(#[files("src/tests/tvix_tests/identity-*.nix")] code_path: PathBuf) { let code = std::fs::read_to_string(code_path).expect("should be able to read test code"); - let eval = crate::Evaluation { - strict: true, - io_handle: Box::new(crate::StdIO) as Box, - ..Default::default() - }; + let mut eval = crate::Evaluation::new(Box::new(crate::StdIO) as Box, false); + eval.strict = true; let result = eval.evaluate(&code, None); assert!( diff --git a/tvix/eval/src/tests/one_offs.rs b/tvix/eval/src/tests/one_offs.rs index 6024058a1296..565d1dd48f77 100644 --- a/tvix/eval/src/tests/one_offs.rs +++ b/tvix/eval/src/tests/one_offs.rs @@ -25,7 +25,7 @@ fn test_source_builtin() { #[test] fn skip_broken_bytecode() { - let result = Evaluation::default().evaluate(/* code = */ "x", None); + let result = Evaluation::new_pure().evaluate(/* code = */ "x", None); assert_eq!(result.errors.len(), 1); -- cgit 1.4.1