Skip to content

Commit b42b63f

Browse files
Merge pull request #21795 from Wilfred/fix_unit_test_rust_project
internal: Fix test_loading_rust_analyzer when rust-project.json is present
2 parents 3df3726 + f69d83e commit b42b63f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

crates/load-cargo/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,15 @@ mod tests {
745745

746746
#[test]
747747
fn test_loading_rust_analyzer() {
748-
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
748+
let cargo_toml_path = Path::new(env!("CARGO_MANIFEST_DIR"))
749+
.parent()
750+
.unwrap()
751+
.parent()
752+
.unwrap()
753+
.join("Cargo.toml");
754+
let cargo_toml_path = AbsPathBuf::assert_utf8(cargo_toml_path);
755+
let manifest = ProjectManifest::from_manifest_file(cargo_toml_path).unwrap();
756+
749757
let cargo_config = CargoConfig { set_test: true, ..CargoConfig::default() };
750758
let load_cargo_config = LoadCargoConfig {
751759
load_out_dirs_from_check: false,
@@ -754,8 +762,9 @@ mod tests {
754762
num_worker_threads: 1,
755763
proc_macro_processes: 1,
756764
};
765+
let workspace = ProjectWorkspace::load(manifest, &cargo_config, &|_| {}).unwrap();
757766
let (db, _vfs, _proc_macro) =
758-
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {}).unwrap();
767+
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config).unwrap();
759768

760769
let n_crates = db.all_crates().len();
761770
// RA has quite a few crates, but the exact count doesn't matter

0 commit comments

Comments
 (0)