From e4d6d20aa7edf82a741b349b520242cd7381aa2e Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 13 Dec 2023 11:37:29 +0200 Subject: test(tvix/glue): add nonexisting_path_without_import test This moves the failing example from cl/10285 into its separate test case. There were multiple complications: tvix-[ca]store was panicking in some places, rather than returning an error. This is now fixed. It needs to live in tvix-glue, so we actually have a "proper" EvalIO interface doing something. > toString ({ line = 42; col = 42; file = /deep/thought; }.file) Should not cause an error, because it shouldn't trigger an import, but leave the path as-is, and not care about it not being present. Change-Id: I76f70b3cb1f73a0fb05870375710fd9f67d5603c Reviewed-on: https://cl.tvl.fyi/c/depot/+/10342 Tested-by: BuildkiteCI Reviewed-by: raitobezarius Autosubmit: flokli Reviewed-by: sterni --- tvix/glue/src/tvix_store_io.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tvix/glue/src') 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), + } + } } -- cgit 1.4.1