Merge pull request #21795 from Wilfred/fix_unit_test_rust_project

internal: Fix test_loading_rust_analyzer when rust-project.json is present
This commit is contained in:
Chayim Refael Friedman
2026-03-22 23:15:25 +00:00
committed by GitHub
@@ -745,7 +745,15 @@ mod tests {
#[test]
fn test_loading_rust_analyzer() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
let cargo_toml_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.join("Cargo.toml");
let cargo_toml_path = AbsPathBuf::assert_utf8(cargo_toml_path);
let manifest = ProjectManifest::from_manifest_file(cargo_toml_path).unwrap();
let cargo_config = CargoConfig { set_test: true, ..CargoConfig::default() };
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: false,
@@ -754,8 +762,9 @@ fn test_loading_rust_analyzer() {
num_worker_threads: 1,
proc_macro_processes: 1,
};
let workspace = ProjectWorkspace::load(manifest, &cargo_config, &|_| {}).unwrap();
let (db, _vfs, _proc_macro) =
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {}).unwrap();
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config).unwrap();
let n_crates = db.all_crates().len();
// RA has quite a few crates, but the exact count doesn't matter