From e61aa740983591e287dd053afeabb526baf68fc6 Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Thu, 20 Jul 2023 16:04:34 -0700 Subject: [PATCH] Snapshot tests: canonicalize with dunce This uses dunce [0] to consistently canonicalize paths used in Turbopack's tests. Previously, `REPO_ROOT` used Windows UNC paths while the test path in snapshot tests did not. This caused an issue when using `string.strip_prefix()` to determine relative paths. [0] https://crates.io/crates/dunce --- crates/turbopack-tests/tests/snapshot.rs | 2 +- crates/turbopack-tests/tests/util.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/turbopack-tests/tests/snapshot.rs b/crates/turbopack-tests/tests/snapshot.rs index 29a14698e6d65..e2ed3a5ab9101 100644 --- a/crates/turbopack-tests/tests/snapshot.rs +++ b/crates/turbopack-tests/tests/snapshot.rs @@ -169,7 +169,7 @@ async fn run(resource: PathBuf) -> Result<()> { #[turbo_tasks::function] async fn run_test(resource: String) -> Result> { - let test_path = Path::new(&resource); + let test_path = canonicalize(Path::new(&resource))?; assert!(test_path.exists(), "{} does not exist", resource); assert!( test_path.is_dir(), diff --git a/crates/turbopack-tests/tests/util.rs b/crates/turbopack-tests/tests/util.rs index bf2545da0e699..6723b8e7f6c93 100644 --- a/crates/turbopack-tests/tests/util.rs +++ b/crates/turbopack-tests/tests/util.rs @@ -1,5 +1,6 @@ -use std::{fs::canonicalize, path::PathBuf}; +use std::path::PathBuf; +use dunce::canonicalize; use once_cell::sync::Lazy; /// The turbo repo root. Should be used as the root when building with turbopack