mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix tests being non-deterministic
This commit is contained in:
parent
0485a85ee2
commit
cdb8c3a327
10 changed files with 221 additions and 175 deletions
|
@ -98,6 +98,11 @@ fn get_test_json_file<T: DeserializeOwned>(file: &str) -> T {
|
|||
}
|
||||
}
|
||||
|
||||
fn replace_cargo(s: &mut String) {
|
||||
let path = toolchain::Tool::Cargo.path().to_string().escape_debug().collect::<String>();
|
||||
*s = s.replace(&path, "$CARGO$");
|
||||
}
|
||||
|
||||
fn replace_root(s: &mut String, direction: bool) {
|
||||
if direction {
|
||||
let root = if cfg!(windows) { r#"C:\\ROOT\"# } else { "/ROOT/" };
|
||||
|
@ -156,7 +161,9 @@ fn to_crate_graph(project_workspace: ProjectWorkspace) -> (CrateGraph, ProcMacro
|
|||
|
||||
fn check_crate_graph(crate_graph: CrateGraph, expect: ExpectFile) {
|
||||
let mut crate_graph = format!("{crate_graph:#?}");
|
||||
|
||||
replace_root(&mut crate_graph, false);
|
||||
replace_cargo(&mut crate_graph);
|
||||
replace_fake_sys_root(&mut crate_graph);
|
||||
expect.assert_eq(&crate_graph);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue