about summary refs log tree commit diff
path: root/tvix/glue/src/builtins
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-01-12T20·34+0100
committerraitobezarius <tvl@lahfa.xyz>2024-01-12T22·32+0000
commit61209f077540d167134b74657f7b067f550ba5c6 (patch)
tree7a06c40ef506e233681227719a386408d99c2ce5 /tvix/glue/src/builtins
parentd516ce56b1fe8b765e8833edb1568817158b306f (diff)
feat(tvix/glue): input derivation context tests r/7377
`args` was not propagating context, here's a regression test for it.

Change-Id: I8b6a3148508d40df0077128f0bafe68c098a03bd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10610
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/glue/src/builtins')
-rw-r--r--tvix/glue/src/builtins/mod.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tvix/glue/src/builtins/mod.rs b/tvix/glue/src/builtins/mod.rs
index d5d42bcec911..3656bb9d1616 100644
--- a/tvix/glue/src/builtins/mod.rs
+++ b/tvix/glue/src/builtins/mod.rs
@@ -246,6 +246,38 @@ mod tests {
         }
     }
 
+    #[test_case(r#"
+                   let
+                     bar = builtins.derivation {
+                       name = "bar";
+                       builder = ":";
+                       system = ":";
+                       outputHash = "08813cbee9903c62be4c5027726a418a300da4500b2d369d3af9286f4815ceba";
+                       outputHashAlgo = "sha256";
+                       outputHashMode = "recursive";
+                     };
+                   in
+                   (builtins.derivation {
+                     name = "foo";
+                     builder = ":";
+                     args = [ "${bar}" ];
+                     system = ":";
+                   }).drvPath
+        "#, "/nix/store/50yl2gmmljyl0lzyrp1mcyhn53vhjhkd-foo.drv"; "input in `args`")]
+    fn test_inputs_derivation_from_context(code: &str, expected_drvpath: &str) {
+        let eval_result = eval(code);
+
+        let value = eval_result.value.expect("must succeed");
+
+        match value {
+            tvix_eval::Value::String(s) => {
+                assert_eq!(expected_drvpath, s.as_str());
+            }
+
+            _ => panic!("unexpected value type: {:?}", value),
+        };
+    }
+
     #[test]
     fn builtins_placeholder_hashes() {
         assert_eq!(