diff options
author | Florian Klink <flokli@flokli.de> | 2023-12-13T09·37+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-12-14T13·25+0000 |
commit | e4d6d20aa7edf82a741b349b520242cd7381aa2e (patch) | |
tree | c63400b5abb32a68de2a3d8459a70024fd518233 | |
parent | 7165ebc43bfb1b53929fb31673c512bbbdbe4096 (diff) |
test(tvix/glue): add nonexisting_path_without_import test r/7219
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 <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Reviewed-by: sterni <sternenseemann@systemli.org>
-rw-r--r-- | tvix/glue/src/tvix_store_io.rs | 18 |
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), + } + } } |