mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Move dedup-dev-deps tests into rust-analyzer crate
This commit is contained in:
parent
b1404d387a
commit
0ccb3b8731
8 changed files with 233 additions and 152 deletions
|
@ -238,7 +238,7 @@ fn crate_graph_dedup_identical() {
|
|||
|
||||
let (d_crate_graph, mut d_proc_macros) = (crate_graph.clone(), proc_macros.clone());
|
||||
|
||||
crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros, |_, _| true);
|
||||
crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros, |(_, a), (_, b)| a == b);
|
||||
assert!(crate_graph.iter().eq(d_crate_graph.iter()));
|
||||
assert_eq!(proc_macros, d_proc_macros);
|
||||
}
|
||||
|
@ -254,62 +254,10 @@ fn crate_graph_dedup() {
|
|||
load_cargo_with_fake_sysroot(path_map, "regex-metadata.json");
|
||||
assert_eq!(regex_crate_graph.iter().count(), 60);
|
||||
|
||||
crate_graph.extend(regex_crate_graph, &mut regex_proc_macros, |_, _| true);
|
||||
crate_graph.extend(regex_crate_graph, &mut regex_proc_macros, |(_, a), (_, b)| a == b);
|
||||
assert_eq!(crate_graph.iter().count(), 118);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deduplicate_origin_dev() {
|
||||
let path_map = &mut Default::default();
|
||||
let (mut crate_graph, _proc_macros) =
|
||||
load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_A.json");
|
||||
crate_graph.sort_deps();
|
||||
let (crate_graph_1, mut _proc_macros_2) =
|
||||
load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_B.json");
|
||||
|
||||
crate_graph.extend(crate_graph_1, &mut _proc_macros_2, |_, _| true);
|
||||
|
||||
let mut crates_named_p2 = vec![];
|
||||
for id in crate_graph.iter() {
|
||||
let krate = &crate_graph[id];
|
||||
if let Some(name) = krate.display_name.as_ref() {
|
||||
if name.to_string() == "p2" {
|
||||
crates_named_p2.push(krate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(crates_named_p2.len() == 1);
|
||||
let p2 = crates_named_p2[0];
|
||||
assert!(p2.origin.is_local());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deduplicate_origin_dev_rev() {
|
||||
let path_map = &mut Default::default();
|
||||
let (mut crate_graph, _proc_macros) =
|
||||
load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_B.json");
|
||||
crate_graph.sort_deps();
|
||||
let (crate_graph_1, mut _proc_macros_2) =
|
||||
load_cargo_with_fake_sysroot(path_map, "deduplication_crate_graph_A.json");
|
||||
|
||||
crate_graph.extend(crate_graph_1, &mut _proc_macros_2, |_, _| true);
|
||||
|
||||
let mut crates_named_p2 = vec![];
|
||||
for id in crate_graph.iter() {
|
||||
let krate = &crate_graph[id];
|
||||
if let Some(name) = krate.display_name.as_ref() {
|
||||
if name.to_string() == "p2" {
|
||||
crates_named_p2.push(krate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(crates_named_p2.len() == 1);
|
||||
let p2 = crates_named_p2[0];
|
||||
assert!(p2.origin.is_local());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke_test_real_sysroot_cargo() {
|
||||
if std::env::var("SYSROOT_CARGO_METADATA").is_err() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue