Skip to content

Commit e92d793

Browse files
Auto merge of #147372 - jieyouxu:rust-analyzer-main-tests, r=<try>
Run main rust-analyzer tests in rust-lang/rust CI try-job: aarch64-gnu try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-1 try-job: x86_64-msvc-1 try-job: aarch64-msvc-1
2 parents c871d09 + ca2cd06 commit e92d793

File tree

32 files changed

+160
-18
lines changed

32 files changed

+160
-18
lines changed

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

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -445,35 +445,52 @@ impl Step for RustAnalyzer {
445445

446446
/// Runs `cargo test` for rust-analyzer
447447
fn run(self, builder: &Builder<'_>) {
448-
let host = self.compilers.target();
448+
let tool_result = builder.ensure(tool::RustAnalyzer::from_compilers(self.compilers));
449+
let build_compiler = tool_result.build_compiler;
450+
let target = self.compilers.target();
449451

450-
let workspace_path = "src/tools/rust-analyzer";
451-
// until the whole RA test suite runs on `i686`, we only run
452-
// `proc-macro-srv` tests
453-
let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv";
454452
let mut cargo = tool::prepare_tool_cargo(
455453
builder,
456-
self.compilers.build_compiler(),
454+
build_compiler,
457455
Mode::ToolRustcPrivate,
458-
host,
456+
target,
459457
Kind::Test,
460-
crate_path,
458+
"src/tools/rust-analyzer",
461459
SourceType::InTree,
462460
&["in-rust-tree".to_owned()],
463461
);
464462
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);
465463

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

471-
// RA's test suite tries to write to the source directory, that can't
472-
// work in Rust CI
468+
// FIXME: RA's test suite tries to write to the source directory, that can't work in Rust CI
469+
// without properly wiring up the writable test dir.
473470
cargo.env("SKIP_SLOW_TESTS", "1");
474471

472+
// NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
473+
// stable rustfmt.
474+
//
475+
// NOTE: you can only skip a specific workspace package via `--exclude=...` if you *also*
476+
// specify `--workspace`.
477+
cargo.arg("--workspace");
478+
cargo.arg("--exclude=xtask");
479+
480+
let mut skip_tests = vec![];
481+
482+
// Across all platforms
483+
skip_tests.extend_from_slice(&[
484+
// FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
485+
// in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
486+
"tests::smoke_test_real_sysroot_cargo",
487+
]);
488+
489+
let skip_tests = skip_tests.iter().map(|name| format!("--skip={name}")).collect::<Vec<_>>();
490+
let skip_tests = skip_tests.iter().map(|s| s.as_str()).collect::<Vec<_>>();
491+
475492
cargo.add_rustc_lib_path(builder);
476-
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
493+
run_cargo_test(cargo, skip_tests.as_slice(), &[], "rust-analyzer", target, builder);
477494
}
478495

479496
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>

src/tools/rust-analyzer/crates/base-db/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ vfs.workspace = true
3131
span.workspace = true
3232
intern.workspace = true
3333

34+
[features]
35+
default = []
36+
in-rust-tree = []
37+
3438
[lints]
3539
workspace = true

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! base_db defines basic database traits. The concrete DB is defined by ide.
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg(feature = "in-rust-tree")]
6+
extern crate rustc_driver as _;
7+
38
pub use salsa;
49
pub use salsa_macros;
510

src/tools/rust-analyzer/crates/cfg/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ syntax.workspace = true
3232
# tt is needed for testing
3333
cfg = { path = ".", default-features = false, features = ["tt"] }
3434

35+
[features]
36+
default = []
37+
in-rust-tree = []
38+
3539
[lints]
3640
workspace = true

src/tools/rust-analyzer/crates/cfg/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg(feature = "in-rust-tree")]
6+
extern crate rustc_driver as _;
7+
38
mod cfg_expr;
49
mod dnf;
510
#[cfg(test)]

src/tools/rust-analyzer/crates/ide-completion/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ expect-test = "1.5.1"
3737
test-utils.workspace = true
3838
test-fixture.workspace = true
3939

40+
[features]
41+
default = []
42+
in-rust-tree = []
43+
4044
[lints]
4145
workspace = true

src/tools/rust-analyzer/crates/ide-completion/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! `completions` crate provides utilities for generating completions of user input.
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg(feature = "in-rust-tree")]
6+
extern crate rustc_driver as _;
7+
38
mod completions;
49
mod config;
510
mod context;

src/tools/rust-analyzer/crates/ide-db/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ line-index.workspace = true
5252
[dev-dependencies]
5353
expect-test = "1.5.1"
5454

55+
[features]
56+
default = []
57+
in-rust-tree = []
58+
5559
[lints]
5660
workspace = true

src/tools/rust-analyzer/crates/ide-db/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
//!
33
//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
44
5+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
6+
7+
#[cfg(feature = "in-rust-tree")]
8+
extern crate rustc_driver as _;
9+
510
extern crate self as ide_db;
611

712
mod apply_change;

0 commit comments

Comments
 (0)