-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Running `cargo test` on Windows gets flaky when calling `canonicalize()` on Path. This is because on Windows, the disk pathing for an absolute path starts with `//?/C:/foo/bar/`. See Rust GitHub issue and discussion here [1]. To resolve, add a helper function that remove the `//?/` from the canonical path. [1] - rust-lang/rust#42869
- Loading branch information
Showing
4 changed files
with
24 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pub mod archive; | |
pub mod cli; | ||
pub mod git; | ||
pub mod http; | ||
pub mod paths; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! Utility functions for working with paths | ||
use std::path::{Path, PathBuf}; | ||
/// On Windows removes the `\\?\\` prefix to UNC paths. | ||
/// For other OS'es just turns the `Path` into a `PathBuf` | ||
#[must_use] | ||
pub fn fix_unc_path(res: &Path) -> PathBuf { | ||
if cfg!(windows) { | ||
let res_str = res.display().to_string(); | ||
if res_str.starts_with(r#"\\?"#) { | ||
PathBuf::from(res_str.replace(r#"\\?\"#, "")) | ||
} else { | ||
res.to_path_buf() | ||
} | ||
} else { | ||
res.to_path_buf() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters