Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,35 +446,52 @@ impl Step for RustAnalyzer {

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

let workspace_path = "src/tools/rust-analyzer";
// until the whole RA test suite runs on `i686`, we only run
// `proc-macro-srv` tests
let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv";
let mut cargo = tool::prepare_tool_cargo(
builder,
self.compilers.build_compiler(),
build_compiler,
Mode::ToolRustcPrivate,
host,
target,
Kind::Test,
crate_path,
"src/tools/rust-analyzer",
SourceType::InTree,
&["in-rust-tree".to_owned()],
);
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);

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

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

// NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
// stable rustfmt.
//
// NOTE: you can only skip a specific workspace package via `--exclude=...` if you *also*
// specify `--workspace`.
cargo.arg("--workspace");
cargo.arg("--exclude=xtask");

let mut skip_tests = vec![];

// Across all platforms
skip_tests.extend_from_slice(&[
// FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
// in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
"tests::smoke_test_real_sysroot_cargo",
]);

let skip_tests = skip_tests.iter().map(|name| format!("--skip={name}")).collect::<Vec<_>>();
let skip_tests = skip_tests.iter().map(|s| s.as_str()).collect::<Vec<_>>();

cargo.add_rustc_lib_path(builder);
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
run_cargo_test(cargo, skip_tests.as_slice(), &[], "rust-analyzer", target, builder);
}

fn metadata(&self) -> Option<StepMetadata> {
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,7 @@ mod snapshot {
[build] rustc 0 <host> -> Linkchecker 1 <host>
[test] link-check <host>
[test] tier-check <host>
[build] rustc 0 <host> -> rust-analyzer 1 <host>
[test] rustc 0 <host> -> rust-analyzer 1 <host>
[build] rustc 0 <host> -> RustdocTheme 1 <host>
[test] rustdoc-theme 1 <host>
Expand Down Expand Up @@ -2296,6 +2297,7 @@ mod snapshot {
[build] rustc 0 <host> -> Linkchecker 1 <host>
[test] link-check <host>
[test] tier-check <host>
[build] rustc 1 <host> -> rust-analyzer 2 <host>
[test] rustc 1 <host> -> rust-analyzer 2 <host>
[doc] rustc (book) <host>
[test] rustc 1 <host> -> lint-docs 2 <host>
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ vfs.workspace = true
span.workspace = true
intern.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! base_db defines basic database traits. The concrete DB is defined by ide.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

pub use salsa;
pub use salsa_macros;

Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ derive_arbitrary = "1.4.1"
syntax-bridge.workspace = true
syntax.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/cfg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod cfg_expr;
mod dnf;
#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-completion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ expect-test = "1.5.1"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! `completions` crate provides utilities for generating completions of user input.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod completions;
mod config;
mod context;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ expect-test = "1.5.1"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/ide-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
//!
//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod apply_change;

pub mod active_parameter;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ expect-test = "1.5.1"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
//! There are also a couple of ad-hoc diagnostics implemented directly here, we
//! don't yet have a great pattern for how to do them properly.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod handlers {
pub(crate) mod await_outside_of_async;
pub(crate) mod bad_rtn;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-ssr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ triomphe.workspace = true
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/ide-ssr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
// // foo($a, $b) ==>> ($a).foo($b)
// ```

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod fragments;
mod from_comment;
mod matching;
Expand Down
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
//! for incorporating changes.
// Note, don't remove any public api from this. This API is consumed by external tools
// to run rust-analyzer as a library.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

use std::{any::Any, collections::hash_map::Entry, mem, path::Path, sync};

use crossbeam_channel::{Receiver, unbounded};
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
extern crate ra_ap_rustc_lexer as rustc_lexer;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_lexer;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod event;
mod grammar;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ span = { path = "../span", version = "0.0.0", default-features = false}

intern.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
//! is used to provide basic infrastructure for communication between two
//! processes: Client (RA itself), Server (the external program)
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

pub mod legacy_protocol;
mod process;

Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/project-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ toolchain.workspace = true
[dev-dependencies]
expect-test = "1.5.1"

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/project-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
//! procedural macros).
//! * Lowering of concrete model to a [`base_db::CrateGraph`]
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

pub mod project_json;
pub mod toolchain_info {
pub mod rustc_cfg;
Expand Down
10 changes: 7 additions & 3 deletions src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ syntax-bridge.workspace = true
jemalloc = ["jemallocator", "profile/jemalloc"]
force-always-assert = ["stdx/force-always-assert"]
in-rust-tree = [
"syntax/in-rust-tree",
"parser/in-rust-tree",
"hir/in-rust-tree",
"cfg/in-rust-tree",
"hir-def/in-rust-tree",
"hir-ty/in-rust-tree",
"hir/in-rust-tree",
"ide-ssr/in-rust-tree",
"ide/in-rust-tree",
"load-cargo/in-rust-tree",
"parser/in-rust-tree",
"proc-macro-api/in-rust-tree",
"syntax/in-rust-tree",
]

[lints]
Expand Down
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
//! The `cli` submodule implements some batch-processing analysis, primarily as
//! a debugging aid.
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

/// Any toolchain less than this version will likely not work with rust-analyzer built from this revision.
pub const MINIMUM_SUPPORTED_TOOLCHAIN_VERSION: semver::Version = semver::Version {
major: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
//! be sure without a real client anyway.
#![allow(clippy::disallowed_types)]
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod cli;
mod ratoml;
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/span/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ syntax.workspace = true

[features]
default = ["salsa"]
in-rust-tree = []

[lints]
workspace = true
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/crates/span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
//! File and span related types.
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

use std::fmt::{self, Write};

mod ast_id;
Expand Down
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/syntax-bridge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

use std::{fmt, hash::Hash};

use intern::Symbol;
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rustc_apfloat = "0.2.3"
test-utils.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
Expand Down
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
//! [RFC]: <https://github.com/rust-lang/rfcs/pull/2256>
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

mod parsing;
mod ptr;
mod syntax_error;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/test-fixture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ intern.workspace = true
triomphe.workspace = true
paths.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/crates/test-fixture/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
//! A set of high-level utility fixture methods to use in tests.
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;

use std::{any::TypeId, mem, str::FromStr, sync};

use base_db::target::TargetData;
Expand Down
Loading
Loading