From c372fb3495af20f3e76097a782018cc122f3ab78 Mon Sep 17 00:00:00 2001 From: Bruno Ortiz Date: Sat, 8 Apr 2023 15:26:48 -0300 Subject: [PATCH] fixing tests for windows --- crates/project-model/src/tests.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs index ca28d742d5c..c3c654ddb6f 100644 --- a/crates/project-model/src/tests.rs +++ b/crates/project-model/src/tests.rs @@ -103,8 +103,15 @@ fn replace_root(s: &mut String, direction: bool) { } fn replace_fake_sys_root(s: &mut String) { - let root = get_test_path("fake-sysroot"); - *s = s.replace(root.to_str().expect("expected str"), "$FAKESYSROOT$") + let fake_sysroot_path = get_test_path("fake-sysroot"); + let fake_sysroot_path = if cfg!(windows) { + let normalized_path = + fake_sysroot_path.to_str().expect("expected str").replace(r#"\"#, r#"\\"#); + format!(r#"{}\\"#, normalized_path) + } else { + format!("{}/", fake_sysroot_path.to_str().expect("expected str")) + }; + *s = s.replace(&fake_sysroot_path, "$FAKESYSROOT$") } fn get_test_path(file: &str) -> PathBuf {