about summary refs log tree commit diff
path: root/tvix/glue/src/tvix_store_io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/glue/src/tvix_store_io.rs')
-rw-r--r--tvix/glue/src/tvix_store_io.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tvix/glue/src/tvix_store_io.rs b/tvix/glue/src/tvix_store_io.rs
index 611e354414e0..70ec21e74327 100644
--- a/tvix/glue/src/tvix_store_io.rs
+++ b/tvix/glue/src/tvix_store_io.rs
@@ -469,4 +469,22 @@ mod tests {
             import_path_and_compare(tmpdir.path().join("hello.txt"))
         );
     }
+
+    /// Invoke toString on a nonexisting file, and access the .file attribute.
+    /// This should not cause an error, because it shouldn't trigger an import,
+    /// and leave the path as-is.
+    #[test]
+    fn nonexisting_path_without_import() {
+        let result = eval("toString ({ line = 42; col = 42; file = /deep/thought; }.file)");
+
+        assert!(result.errors.is_empty(), "expect evaluation to succeed");
+        let value = result.value.expect("must be some");
+
+        match value {
+            tvix_eval::Value::String(s) => {
+                assert_eq!("/deep/thought", s.as_str());
+            }
+            _ => panic!("unexpected value type: {:?}", value),
+        }
+    }
 }