refactor(tvix/eval): factor out all calls to canon_path

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>
This commit is contained in:
Adam Joseph 2022-10-12 21:58:42 -07:00
parent 534a2f95f8
commit 25336fc47b
4 changed files with 18 additions and 5 deletions

View file

@ -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()
}