about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-12-24T21·46+0200
committerclbot <clbot@tvl.fyi>2024-01-08T11·13+0000
commit17eaacb139029f481ff821768c386061886c7059 (patch)
treea377045cd890339918cfddf9d368a67e6ba82664 /tvix
parent986e9b73c3c1e694fa0cbc4d29440ad8b8938269 (diff)
feat(tvix/glue): add test for output path calculation r/7357
This test serves as a minimal reproducer for output path calculation.

Derivations with the same name and output hash, but different build
recipe should end up with the same outPath.

However derivations with different name should end up with a different
outPath.

Change-Id: I555be59dd87ea675a0816188ed973f96c311e4e1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10416
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/glue/src/builtins/mod.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tvix/glue/src/builtins/mod.rs b/tvix/glue/src/builtins/mod.rs
index 6ae99ba14759..455fdbd0fc37 100644
--- a/tvix/glue/src/builtins/mod.rs
+++ b/tvix/glue/src/builtins/mod.rs
@@ -143,6 +143,42 @@ mod tests {
         );
     }
 
+    /// Construct two FODs with the same name, and same known output (but
+    /// slightly different recipe), ensure they have the same output hash.
+    #[test]
+    fn test_fod_outpath() {
+        let code = r#"
+          (builtins.derivation { name = "foo"; builder = "/bin/sh"; system = "x86_64-linux"; outputHash = "sha256-Q3QXOoy+iN4VK2CflvRulYvPZXYgF0dO7FoF7CvWFTA="; }).outPath ==
+          (builtins.derivation { name = "foo"; builder = "/bin/aa"; system = "x86_64-linux"; outputHash = "sha256-Q3QXOoy+iN4VK2CflvRulYvPZXYgF0dO7FoF7CvWFTA="; }).outPath
+        "#;
+
+        let value = eval(code).value.expect("must succeed");
+        match value {
+            tvix_eval::Value::Bool(v) => {
+                assert!(v);
+            }
+            _ => panic!("unexpected value type: {:?}", value),
+        }
+    }
+
+    /// Construct two FODs with the same name, and same known output (but
+    /// slightly different recipe), ensure they have the same output hash.
+    #[test]
+    fn test_fod_outpath_different_name() {
+        let code = r#"
+          (builtins.derivation { name = "foo"; builder = "/bin/sh"; system = "x86_64-linux"; outputHash = "sha256-Q3QXOoy+iN4VK2CflvRulYvPZXYgF0dO7FoF7CvWFTA="; }).outPath ==
+          (builtins.derivation { name = "foo"; builder = "/bin/aa"; system = "x86_64-linux"; outputHash = "sha256-Q3QXOoy+iN4VK2CflvRulYvPZXYgF0dO7FoF7CvWFTA="; }).outPath
+        "#;
+
+        let value = eval(code).value.expect("must succeed");
+        match value {
+            tvix_eval::Value::Bool(v) => {
+                assert!(v);
+            }
+            _ => panic!("unexpected value type: {:?}", value),
+        }
+    }
+
     /// Construct two derivations with the same parameters except
     /// one of them lost a context string for a dependency, causing
     /// the loss of an element in the `inputDrvs` derivation.