Skip to content

Commit c372fb3

Browse files
committed
fixing tests for windows
1 parent fe7874a commit c372fb3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/project-model/src/tests.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,15 @@ fn replace_root(s: &mut String, direction: bool) {
103103
}
104104

105105
fn replace_fake_sys_root(s: &mut String) {
106-
let root = get_test_path("fake-sysroot");
107-
*s = s.replace(root.to_str().expect("expected str"), "$FAKESYSROOT$")
106+
let fake_sysroot_path = get_test_path("fake-sysroot");
107+
let fake_sysroot_path = if cfg!(windows) {
108+
let normalized_path =
109+
fake_sysroot_path.to_str().expect("expected str").replace(r#"\"#, r#"\\"#);
110+
format!(r#"{}\\"#, normalized_path)
111+
} else {
112+
format!("{}/", fake_sysroot_path.to_str().expect("expected str"))
113+
};
114+
*s = s.replace(&fake_sysroot_path, "$FAKESYSROOT$")
108115
}
109116

110117
fn get_test_path(file: &str) -> PathBuf {

0 commit comments

Comments
 (0)