about summary refs log tree commit diff
path: root/tvix/glue/src/tests
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-01-16T04·31+0100
committerclbot <clbot@tvl.fyi>2024-01-18T14·28+0000
commit12ae96cff2e925f502cee8afb4f8dcf54aba27d8 (patch)
tree661f8bf7401b524d9ac3dc6770eddd10b3bdb4d7 /tvix/glue/src/tests
parent43b9e25025eef302369ff27074bfa5bbfb1c7115 (diff)
feat(tvix/glue): use TvixStoreIO as derivation builtin state r/7410
We propagate a `TvixStoreIO` as the `state` of our derivation-specific
builtins in the glue crate.

The evaluators `io_handle` itself is using a Rc<dyn EvalIO>.

An earlier version of TvixStoreIO was also introducing generics over the
different internal services themselves, but we opted for instead
hardcoding this to Arc<dyn …> for the sake of less macro voodoo.

Change-Id: I535c476f06b840858fa3070c4a237ece47f7a15b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10636
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/glue/src/tests')
-rw-r--r--tvix/glue/src/tests/mod.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/tvix/glue/src/tests/mod.rs b/tvix/glue/src/tests/mod.rs
index 9ae17c219ac9..b5b62c5d7e4c 100644
--- a/tvix/glue/src/tests/mod.rs
+++ b/tvix/glue/src/tests/mod.rs
@@ -1,4 +1,4 @@
-use std::{cell::RefCell, rc::Rc, sync::Arc};
+use std::{rc::Rc, sync::Arc};
 
 use pretty_assertions::assert_eq;
 use std::path::PathBuf;
@@ -6,14 +6,12 @@ use tvix_castore::{
     blobservice::{BlobService, MemoryBlobService},
     directoryservice::{DirectoryService, MemoryDirectoryService},
 };
-use tvix_eval::Value;
+use tvix_eval::{EvalIO, Value};
 use tvix_store::pathinfoservice::{MemoryPathInfoService, PathInfoService};
 
 use rstest::rstest;
 
-use crate::{
-    builtins::add_derivation_builtins, known_paths::KnownPaths, tvix_store_io::TvixStoreIO,
-};
+use crate::{builtins::add_derivation_builtins, tvix_store_io::TvixStoreIO};
 
 fn eval_test(code_path: PathBuf, expect_success: bool) {
     assert_eq!(
@@ -32,8 +30,6 @@ fn eval_test(code_path: PathBuf, expect_success: bool) {
         return;
     }
 
-    let mut eval = tvix_eval::Evaluation::new_impure();
-
     let blob_service = Arc::new(MemoryBlobService::default()) as Arc<dyn BlobService>;
     let directory_service =
         Arc::new(MemoryDirectoryService::default()) as Arc<dyn DirectoryService>;
@@ -41,19 +37,18 @@ fn eval_test(code_path: PathBuf, expect_success: bool) {
         blob_service.clone(),
         directory_service.clone(),
     )) as Box<dyn PathInfoService>;
-    let runtime = tokio::runtime::Runtime::new().unwrap();
+    let tokio_runtime = tokio::runtime::Runtime::new().unwrap();
 
-    eval.io_handle = Box::new(TvixStoreIO::new(
+    let tvix_store_io = Rc::new(TvixStoreIO::new(
         blob_service,
         directory_service,
-        path_info_service,
-        runtime.handle().clone(),
+        path_info_service.into(),
+        tokio_runtime.handle().clone(),
     ));
-
-    let known_paths: Rc<RefCell<KnownPaths>> = Default::default();
+    let mut eval = tvix_eval::Evaluation::new(tvix_store_io.clone() as Rc<dyn EvalIO>, true);
 
     eval.strict = true;
-    add_derivation_builtins(&mut eval, known_paths.clone());
+    add_derivation_builtins(&mut eval, tvix_store_io.clone());
 
     let result = eval.evaluate(code, Some(code_path.clone()));
     let failed = match result.value {