Skip to content

Commit 867471f

Browse files
Auto merge of #147372 - jieyouxu:rust-analyzer-main-tests, r=<try>
[DO NOT MERGE] Run main rust-analyzer tests 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 e2c96cc + bcc2aae commit 867471f

File tree

33 files changed

+179
-22
lines changed

33 files changed

+179
-22
lines changed

src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ impl Step for TheBook {
274274

275275
// build the redirect pages
276276
let _guard = builder.msg(Kind::Doc, "book redirect pages", None, build_compiler, target);
277+
if builder.config.dry_run() {
278+
return;
279+
}
280+
277281
for file in t!(fs::read_dir(redirect_path)) {
278282
let file = t!(file);
279283
let path = file.path();

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

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -446,35 +446,61 @@ impl Step for RustAnalyzer {
446446

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

451-
let workspace_path = "src/tools/rust-analyzer";
452-
// until the whole RA test suite runs on `i686`, we only run
453-
// `proc-macro-srv` tests
454-
let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv";
455455
let mut cargo = tool::prepare_tool_cargo(
456456
builder,
457-
self.compilers.build_compiler(),
457+
build_compiler,
458458
Mode::ToolRustcPrivate,
459-
host,
459+
target,
460460
Kind::Test,
461-
crate_path,
461+
"src/tools/rust-analyzer",
462462
SourceType::InTree,
463463
&["in-rust-tree".to_owned()],
464464
);
465465
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);
466466

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

472-
// RA's test suite tries to write to the source directory, that can't
473-
// work in Rust CI
471+
// FIXME: RA's test suite tries to write to the source directory, that can't work in Rust CI
472+
// without properly wiring up the writable test dir.
474473
cargo.env("SKIP_SLOW_TESTS", "1");
474+
// FIXME: teach rust-analyzer to use `RUST_ANALYZER_TEST_DIR` for its test output root
475+
// directory. In the rust-lang/rust CI, we separate checkout directory vs build directory,
476+
// where the checkout directory is read-only whereas build directory (including test output
477+
// directories) is writable.
478+
let dir = testdir(builder, target);
479+
t!(fs::create_dir_all(&dir));
480+
cargo.env("RUST_ANALYZER_TEST_DIR", dir);
481+
482+
// NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
483+
// stable rustfmt.
484+
//
485+
// NOTE: you can only skip a specific workspace package via `--skip=...` if you *also*
486+
// specify `--workspace`.
487+
cargo.arg("--workspace");
488+
cargo.arg("--exclude=xtask");
489+
490+
let mut skip_tests = vec![];
491+
492+
// Across all platforms
493+
skip_tests.extend_from_slice(&[
494+
// FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
495+
// in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
496+
"tests::smoke_test_real_sysroot_cargo",
497+
]);
498+
499+
let skip_tests = skip_tests.iter().map(|name| format!("--skip={name}")).collect::<Vec<_>>();
500+
let skip_tests = skip_tests.iter().map(|s| s.as_str()).collect::<Vec<_>>();
475501

476502
cargo.add_rustc_lib_path(builder);
477-
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
503+
run_cargo_test(cargo, skip_tests.as_slice(), &[], "rust-analyzer", test_compiler, builder);
478504
}
479505

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

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,12 +1270,12 @@ mod snapshot {
12701270
[doc] book/first-edition (book) <host>
12711271
[doc] book/second-edition (book) <host>
12721272
[doc] book/2018-edition (book) <host>
1273-
[build] rustdoc 1 <host>
12741273
[build] rustc 1 <host> -> std 1 <target1>
12751274
[doc] book (book) <target1>
12761275
[doc] book/first-edition (book) <target1>
12771276
[doc] book/second-edition (book) <target1>
12781277
[doc] book/2018-edition (book) <target1>
1278+
[build] rustdoc 1 <host>
12791279
[doc] rustc 1 <host> -> standalone 2 <host>
12801280
[doc] rustc 1 <host> -> standalone 2 <target1>
12811281
[doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
@@ -1409,12 +1409,12 @@ mod snapshot {
14091409
[doc] book/first-edition (book) <host>
14101410
[doc] book/second-edition (book) <host>
14111411
[doc] book/2018-edition (book) <host>
1412-
[build] rustdoc 1 <host>
14131412
[build] rustc 1 <host> -> std 1 <target1>
14141413
[doc] book (book) <target1>
14151414
[doc] book/first-edition (book) <target1>
14161415
[doc] book/second-edition (book) <target1>
14171416
[doc] book/2018-edition (book) <target1>
1417+
[build] rustdoc 1 <host>
14181418
[doc] rustc 1 <host> -> standalone 2 <host>
14191419
[doc] rustc 1 <host> -> standalone 2 <target1>
14201420
[doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
@@ -1493,8 +1493,8 @@ mod snapshot {
14931493
[doc] book/first-edition (book) <target1>
14941494
[doc] book/second-edition (book) <target1>
14951495
[doc] book/2018-edition (book) <target1>
1496-
[build] rustdoc 1 <host>
14971496
[build] rustc 1 <host> -> std 1 <host>
1497+
[build] rustdoc 1 <host>
14981498
[doc] rustc 1 <host> -> standalone 2 <target1>
14991499
[doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
15001500
[doc] nomicon (book) <target1>
@@ -1537,8 +1537,8 @@ mod snapshot {
15371537
[doc] book/first-edition (book) <target1>
15381538
[doc] book/second-edition (book) <target1>
15391539
[doc] book/2018-edition (book) <target1>
1540-
[build] rustdoc 1 <host>
15411540
[build] rustc 1 <host> -> std 1 <host>
1541+
[build] rustdoc 1 <host>
15421542
[doc] rustc 1 <host> -> standalone 2 <target1>
15431543
[doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
15441544
[build] llvm <target1>
@@ -2112,6 +2112,7 @@ mod snapshot {
21122112
[build] rustc 0 <host> -> Linkchecker 1 <host>
21132113
[test] link-check <host>
21142114
[test] tier-check <host>
2115+
[build] rustc 0 <host> -> rust-analyzer 1 <host>
21152116
[test] rustc 0 <host> -> rust-analyzer 1 <host>
21162117
[build] rustc 0 <host> -> RustdocTheme 1 <host>
21172118
[test] rustdoc-theme 1 <host>
@@ -2296,6 +2297,7 @@ mod snapshot {
22962297
[build] rustc 0 <host> -> Linkchecker 1 <host>
22972298
[test] link-check <host>
22982299
[test] tier-check <host>
2300+
[build] rustc 1 <host> -> rust-analyzer 2 <host>
22992301
[test] rustc 1 <host> -> rust-analyzer 2 <host>
23002302
[doc] rustc (book) <host>
23012303
[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
@@ -33,5 +33,9 @@ derive_arbitrary = "1.4.1"
3333
syntax-bridge.workspace = true
3434
syntax.workspace = true
3535

36+
[features]
37+
default = []
38+
in-rust-tree = []
39+
3640
[lints]
3741
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
@@ -36,5 +36,9 @@ expect-test = "1.5.1"
3636
test-utils.workspace = true
3737
test-fixture.workspace = true
3838

39+
[features]
40+
default = []
41+
in-rust-tree = []
42+
3943
[lints]
4044
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 @@ expect-test = "1.5.1"
5252
test-utils.workspace = true
5353
test-fixture.workspace = true
5454

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

0 commit comments

Comments
 (0)