diff options
author | Adam Joseph <adam@westernsemico.com> | 2022-10-13T04·58-0700 |
---|---|---|
committer | Adam Joseph <adam@westernsemico.com> | 2022-10-13T09·07+0000 |
commit | 25336fc47b02fe90bf489402ed84f8259aa80ca8 (patch) | |
tree | fdeb65567b25173052fae52e4229e4ba8b77406b /tvix/eval/src/value | |
parent | 534a2f95f86f3b0340040261ffc428d604210512 (diff) |
refactor(tvix/eval): factor out all calls to canon_path r/5119
Right now we're pretending that the Rust library path_clean does the same thing that cppnix's canonPath() does. This is not true. It's close enough for the test suite, but may come back to bite us. Let's create our own canon_path() function and call that in all the places where we intend to match the behavior of cppnix's canonPath(). That way when we fix this we can fix it once, in one place. Signed-off-by: Adam Joseph <adam@westernsemico.com> Change-Id: Ia6f9577f62f49ef352ff9cfa5efdf37c32d31b11 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6993 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r-- | tvix/eval/src/value/mod.rs | 2 | ||||
-rw-r--r-- | tvix/eval/src/value/path.rs | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index b8b46b444fe7..c8c8a54a40c3 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -11,6 +11,7 @@ mod attrs; mod builtin; mod function; mod list; +mod path; mod string; mod thunk; @@ -21,6 +22,7 @@ pub use attrs::NixAttrs; pub use builtin::Builtin; pub use function::{Closure, Lambda}; pub use list::NixList; +pub use path::canon_path; pub use string::NixString; pub use thunk::Thunk; diff --git a/tvix/eval/src/value/path.rs b/tvix/eval/src/value/path.rs new file mode 100644 index 000000000000..ad526a8746f8 --- /dev/null +++ b/tvix/eval/src/value/path.rs @@ -0,0 +1,14 @@ +use path_clean::PathClean; +use std::path::PathBuf; + +/// This function should match the behavior of canonPath() in +/// src/libutil/util.cc of cppnix. Currently it does not match that +/// behavior; it uses the `path_clean` library which is based on the +/// Go standard library +/// +/// TODO: make this match the behavior of cppnix +/// TODO: write tests for this + +pub fn canon_path(path: PathBuf) -> PathBuf { + path.clean() +} |