Skip to content

Commit aea6cfd

Browse files
committed
Auto merge of #147372 - jieyouxu:rust-analyzer-main-tests, r=Kobzol
Run main rust-analyzer tests in rust-lang/rust CI Part of rust-lang/rust#147370. MCP: rust-lang/compiler-team#923 This PR prepares `rust-analyzer` crates with `in-rust-tree` cargo featues where needed, and and updates bootstrap to run the main `rust-analyzer` tests in rust-lang/rust CI, not just the `proc-macro-srv` crate tests. This supersedes the earlier attempt at rust-lang/rust#136779. I was honestly expecting more failures in this PR, but looking back at the previous attempt, that makes sense because we no longer run `i686-mingw` (32-bit windows-gnu) which had a _bunch_ of these failures. In the earlier attempt I also disabled the `i686-mingw`-related failures for `i686-msvc` since I didn't feel like digging into 32-bit msvc at the time. Try results from this PR shows that it's most likely limited to 32-bit windows-gnu specifically. ### `rust-analyzer` test remarks - I actually had to _remove_ the `CARGO_WORKSPACE_DIR` `expect-test`-hack in order for `expect-test` to be able to find the test expectation HTML files (for `syntax_highlighting` tests in `ide`). When I added the hack, ironically, it made `expect-test` unable to find the expectation files. I think this was because previously the path was of the `proc-macro-srv` crate specifically, now we point to the root r-a workspace? - The `cfg`-related differences on `aarch64-apple-darwin` might've been fixed? I can't tell, but we don't seem to be observing the differences now. - I'm not sure why `config::{generate_config_documentation, generate_package_json_config}` no longer fails. Perhaps they were fixed to no longer try to write to source directory? ### Review remarks - Commit 1 updates r-a crates that are involved in tests needing artifacts from `rustc_private` compiler crates to use the `in-rust-tree` cargo feature. I briefly tried to use a plain `--cfg=in_rust_tree`, but quickly realized it was very hacky, and needed invasive bootstrap changes. The cargo feature approach seems most "natural"/well-supported to both bootstrap and cargo. - Commit 2 updates bootstrap to not only run the `proc-macro-srv` tests, but the whole r-a tests. - Commit 3 restricts r-a main tests to non-32-bit targets we test in CI, since (1) r-a repo does not run tests against 32-bit platforms, and (2) there are some target pointer width sensitive hash differences causing tests to fail. Notably, this means that we also no longer run r-a `proc-macro-srv` tests against 32-bit targets, but we don't expect that crate to be have target pointer width differences. Discussed this in [#t-compiler/rust-analyzer > 32-bit tests?](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/32-bit.20tests.3F/with/563145736). --- // 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 6effa6a + acb575c commit aea6cfd

File tree

30 files changed

+126
-3
lines changed

30 files changed

+126
-3
lines changed

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

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

crates/cfg/Cargo.toml

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

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

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)]

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

crates/ide-completion/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
// It's useful to refer to code that is private in doc comments.
44
#![allow(rustdoc::private_intra_doc_links)]
55

6+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
7+
8+
#[cfg(feature = "in-rust-tree")]
9+
extern crate rustc_driver as _;
10+
611
mod completions;
712
mod config;
813
mod context;

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

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;

crates/ide-diagnostics/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ expect-test = "1.5.1"
3434
test-utils.workspace = true
3535
test-fixture.workspace = true
3636

37+
[features]
38+
default = []
39+
in-rust-tree = []
40+
3741
[lints]
3842
workspace = true

crates/ide-diagnostics/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
//! There are also a couple of ad-hoc diagnostics implemented directly here, we
2424
//! don't yet have a great pattern for how to do them properly.
2525
26+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
27+
28+
#[cfg(feature = "in-rust-tree")]
29+
extern crate rustc_driver as _;
30+
2631
mod handlers {
2732
pub(crate) mod await_outside_of_async;
2833
pub(crate) mod bad_rtn;

0 commit comments

Comments
 (0)