refactor(tvix/eval): move mocked builtins.derivation to tests
This placeholder should not live in the main crate anymore as we will be injecting the real one from outside of eval, but there are still language tests that depend on a (simple, mockable) version of it. Change-Id: I68ea169db15cbdbeed320930d3069e21e376c90d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7783 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
37883389bc
commit
6b6bd30772
2 changed files with 38 additions and 36 deletions
|
|
@ -1,7 +1,37 @@
|
|||
use builtin_macros::builtins;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use test_generator::test_resources;
|
||||
|
||||
#[builtins]
|
||||
mod mock_builtins {
|
||||
//! Builtins which are required by language tests, but should not
|
||||
//! actually exist in //tvix/eval.
|
||||
use crate::*;
|
||||
|
||||
#[builtin("derivation")]
|
||||
fn builtin_type_of(vm: &mut VM, input: Value) -> Result<Value, ErrorKind> {
|
||||
vm.emit_warning(WarningKind::NotImplemented("builtins.derivation"));
|
||||
|
||||
let input = input.to_attrs()?;
|
||||
let attrs = input.update(NixAttrs::from_iter(
|
||||
[
|
||||
(
|
||||
"outPath",
|
||||
"/nix/store/00000000000000000000000000000000-mock",
|
||||
),
|
||||
(
|
||||
"drvPath",
|
||||
"/nix/store/00000000000000000000000000000000-mock.drv",
|
||||
),
|
||||
("type", "derivation"),
|
||||
]
|
||||
.into_iter(),
|
||||
));
|
||||
|
||||
Ok(Value::Attrs(Box::new(attrs)))
|
||||
}
|
||||
}
|
||||
|
||||
fn eval_test(code_path: &str, expect_success: bool) {
|
||||
let base = code_path
|
||||
.strip_suffix("nix")
|
||||
|
|
@ -17,7 +47,12 @@ fn eval_test(code_path: &str, expect_success: bool) {
|
|||
return;
|
||||
}
|
||||
|
||||
let eval = crate::Evaluation::new_impure(&code, Some(code_path.into()));
|
||||
let mut eval = crate::Evaluation::new_impure(&code, Some(code_path.into()));
|
||||
eval.builtins.extend(
|
||||
mock_builtins::builtins()
|
||||
.into_iter()
|
||||
.map(crate::builtins::builtin_tuple),
|
||||
);
|
||||
|
||||
let result = eval.evaluate();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue