feat(tvix/glue): use TvixStoreIO as derivation builtin state
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>
This commit is contained in:
parent
43b9e25025
commit
12ae96cff2
7 changed files with 124 additions and 102 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue