Skip to content

Commit ebeb60a

Browse files
committed
bootstrap: run full rust-analyzer tests
1 parent 8a66035 commit ebeb60a

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -459,35 +459,67 @@ impl Step for RustAnalyzer {
459459

460460
/// Runs `cargo test` for rust-analyzer
461461
fn run(self, builder: &Builder<'_>) {
462-
let host = self.compilers.target();
462+
let tool_result = builder.ensure(tool::RustAnalyzer::from_compilers(self.compilers));
463+
let build_compiler = tool_result.build_compiler;
464+
let target = self.compilers.target();
463465

464-
let workspace_path = "src/tools/rust-analyzer";
465-
// until the whole RA test suite runs on `i686`, we only run
466-
// `proc-macro-srv` tests
467-
let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv";
468466
let mut cargo = tool::prepare_tool_cargo(
469467
builder,
470-
self.compilers.build_compiler(),
468+
build_compiler,
471469
Mode::ToolRustcPrivate,
472-
host,
470+
target,
473471
Kind::Test,
474-
crate_path,
472+
"src/tools/rust-analyzer",
475473
SourceType::InTree,
476474
&["in-rust-tree".to_owned()],
477475
);
478476
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);
479477

480-
let dir = builder.src.join(workspace_path);
481-
// needed by rust-analyzer to find its own text fixtures, cf.
482-
// https://github.com/rust-analyzer/expect-test/issues/33
483-
cargo.env("CARGO_WORKSPACE_DIR", &dir);
478+
// N.B. it turns out _setting_ `CARGO_WORKSPACE_DIR` actually somehow breaks `expect-test`,
479+
// even though previously we actually needed to set that hack to allow `expect-test` to
480+
// correctly discover the r-a workspace instead of the outer r-l/r workspace.
484481

485-
// RA's test suite tries to write to the source directory, that can't
486-
// work in Rust CI
482+
// FIXME: RA's test suite tries to write to the source directory, that can't work in Rust CI
483+
// without properly wiring up the writable test dir.
487484
cargo.env("SKIP_SLOW_TESTS", "1");
488485

486+
// NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
487+
// stable rustfmt.
488+
//
489+
// NOTE: you can only skip a specific workspace package via `--exclude=...` if you *also*
490+
// specify `--workspace`.
491+
cargo.arg("--workspace");
492+
cargo.arg("--exclude=xtask");
493+
494+
// Skip running tests under `lib/` directory, since those auxiliary libraries cannot depend
495+
// on in-tree details.
496+
cargo.arg("--exclude=la-arena");
497+
cargo.arg("--exclude=line-index");
498+
cargo.arg("--exclude=lsp-server");
499+
cargo.arg("--exclude=smol_str");
500+
cargo.arg("--exclude=text-size");
501+
cargo.arg("--exclude=ungrammar");
502+
503+
let mut skip_tests = vec![];
504+
505+
// NOTE: the following test skips is a bit cheeky in that it assumes there are no
506+
// identically named tests across different r-a packages, where we want to run the
507+
// identically named test in one package but not another. If we want to support that use
508+
// case, we'd have to run the r-a tests in two batches (with one excluding the package that
509+
// we *don't* want to run the test for, and the other batch including).
510+
511+
// Across all platforms.
512+
skip_tests.extend_from_slice(&[
513+
// FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
514+
// in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
515+
"tests::smoke_test_real_sysroot_cargo",
516+
]);
517+
518+
let skip_tests = skip_tests.iter().map(|name| format!("--skip={name}")).collect::<Vec<_>>();
519+
let skip_tests = skip_tests.iter().map(|s| s.as_str()).collect::<Vec<_>>();
520+
489521
cargo.add_rustc_lib_path(builder);
490-
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
522+
run_cargo_test(cargo, skip_tests.as_slice(), &[], "rust-analyzer", target, builder);
491523
}
492524

493525
fn metadata(&self) -> Option<StepMetadata> {

src/bootstrap/src/core/builder/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,7 @@ mod snapshot {
21362136
[build] rustc 0 <host> -> Linkchecker 1 <host>
21372137
[test] link-check <host>
21382138
[test] tier-check <host>
2139+
[build] rustc 0 <host> -> rust-analyzer 1 <host>
21392140
[test] rustc 0 <host> -> rust-analyzer 1 <host>
21402141
[build] rustc 0 <host> -> RustdocTheme 1 <host>
21412142
[test] rustdoc-theme 1 <host>
@@ -2320,6 +2321,7 @@ mod snapshot {
23202321
[build] rustc 0 <host> -> Linkchecker 1 <host>
23212322
[test] link-check <host>
23222323
[test] tier-check <host>
2324+
[build] rustc 1 <host> -> rust-analyzer 2 <host>
23232325
[test] rustc 1 <host> -> rust-analyzer 2 <host>
23242326
[doc] rustc (book) <host>
23252327
[test] rustc 1 <host> -> lint-docs 2 <host>

0 commit comments

Comments
 (0)