MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / normalize_test_path

Function normalize_test_path

crates/chat-cli/src/os/fs/mod.rs:53–74  ·  view source on GitHub ↗
(path: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

51/// implicitly during test runtime.
52#[cfg(test)]
53fn normalize_test_path(path: impl AsRef<Path>) -> PathBuf {
54 #[cfg(windows)]
55 {
56 use typed_path::Utf8TypedPath;
57 let path_ref = path.as_ref();
58
59 // Only process string paths with forward slashes
60 let typed_path = Utf8TypedPath::derive(path_ref.to_str().unwrap());
61 if typed_path.is_unix() {
62 let windows_path = typed_path.with_windows_encoding().to_string();
63
64 // If path is absolute (starts with /) and doesn't already have a drive letter
65 if PathBuf::from(&windows_path).has_root() {
66 // Prepend C: drive letter to make it truly absolute on Windows
67 return PathBuf::from(format!("C:{}", windows_path));
68 }
69
70 return PathBuf::from(windows_path);
71 }
72 }
73 path.as_ref().to_path_buf()
74}
75
76/// Cross-platform path append that handles test paths consistently
77fn append(base: impl AsRef<Path>, path: impl AsRef<Path>) -> PathBuf {

Callers 1

appendFunction · 0.85

Calls 2

to_stringMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected