diff options
| author | Bruno Ortiz <brunortiz11@gmail.com> | 2023-04-08 15:26:48 -0300 |
|---|---|---|
| committer | Bruno Ortiz <brunortiz11@gmail.com> | 2023-05-02 10:59:31 -0300 |
| commit | c372fb3495af20f3e76097a782018cc122f3ab78 (patch) | |
| tree | 0e744cb0554596e3ec1d8790e797e77981cbfdf8 | |
| parent | fe7874af90b9e1190b5aebcf3a6d5544177cf9b2 (diff) | |
| download | rust-c372fb3495af20f3e76097a782018cc122f3ab78.tar.gz rust-c372fb3495af20f3e76097a782018cc122f3ab78.zip | |
fixing tests for windows
| -rw-r--r-- | crates/project-model/src/tests.rs | 11 |
1 files 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 { |
