Add more complex project-model test

This commit is contained in:
Lukas Wirth 2023-04-03 18:10:38 +02:00
parent 707382c21d
commit 980c75bc91
3 changed files with 1584 additions and 1 deletions

View file

@ -5,7 +5,7 @@ use std::{
use base_db::{CrateGraph, FileId, ProcMacroPaths};
use cfg::{CfgAtom, CfgDiff};
use expect_test::{expect, Expect};
use expect_test::{expect, expect_file, Expect, ExpectFile};
use paths::{AbsPath, AbsPathBuf};
use serde::de::DeserializeOwned;
@ -114,6 +114,11 @@ fn check_crate_graph(crate_graph: CrateGraph, expect: Expect) {
replace_root(&mut crate_graph, false);
expect.assert_eq(&crate_graph);
}
fn check_crate_graph_f(crate_graph: CrateGraph, expect: ExpectFile) {
let mut crate_graph = format!("{crate_graph:#?}");
replace_root(&mut crate_graph, false);
expect.assert_eq(&crate_graph);
}
#[test]
fn cargo_hello_world_project_model_with_wildcard_overrides() {
@ -1666,3 +1671,12 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() {
// on the proc_macro sysroot crate.
crate_data.dependencies.iter().find(|&dep| dep.name.deref() == "proc_macro").unwrap();
}
#[test]
fn cargo_dev_dependencies() {
let (crate_graph, _proc_macros) = load_cargo("complex-with-dev-deps.json");
check_crate_graph_f(
crate_graph,
expect_file!["../test_data/cargo_dev_dependencies-crate-graph.txt"],
)
}