Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4ea2f8e

Browse files
Add test step for rust-analyzer, run it by default
1 parent d59abcf commit 4ea2f8e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/bootstrap/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ impl<'a> Builder<'a> {
649649
test::Cargotest,
650650
test::Cargo,
651651
test::Rls,
652+
test::RustAnalyzer,
652653
test::ErrorIndex,
653654
test::Distcheck,
654655
test::RunMakeFullDeps,

src/bootstrap/test.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,55 @@ impl Step for Rls {
352352
}
353353
}
354354

355+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
356+
pub struct RustAnalyzer {
357+
stage: u32,
358+
host: TargetSelection,
359+
}
360+
361+
impl Step for RustAnalyzer {
362+
type Output = ();
363+
const ONLY_HOSTS: bool = true;
364+
const DEFAULT: bool = true;
365+
366+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
367+
run.path("src/tools/rust-analyzer")
368+
}
369+
370+
fn make_run(run: RunConfig<'_>) {
371+
run.builder.ensure(Self { stage: run.builder.top_stage, host: run.target });
372+
}
373+
374+
/// Runs `cargo test` for rust-analyzer
375+
fn run(self, builder: &Builder<'_>) {
376+
let stage = self.stage;
377+
let host = self.host;
378+
let compiler = builder.compiler(stage, host);
379+
380+
builder.ensure(tool::RustAnalyzer { compiler, target: self.host }).expect("in-tree tool");
381+
382+
let path = "src/tools/rust-analyzer";
383+
let mut cargo = tool::prepare_tool_cargo(
384+
builder,
385+
compiler,
386+
Mode::ToolStd,
387+
host,
388+
"test",
389+
path,
390+
SourceType::InTree,
391+
&["rust-analyzer/in-rust-tree".to_owned()],
392+
);
393+
394+
let dir = builder.src.join(path);
395+
cargo.env("CARGO_WORKSPACE_DIR", &dir);
396+
397+
cargo.add_rustc_lib_path(builder, compiler);
398+
cargo.arg("--").args(builder.config.cmd.test_args());
399+
400+
builder.run(&mut cargo.into());
401+
}
402+
}
403+
355404
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
356405
pub struct Rustfmt {
357406
stage: u32,

0 commit comments

Comments
 (0)