From 7537defdfe210740341288cc6f7d639db9ecb058 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 18 Jul 2022 18:20:03 -0700 Subject: [PATCH 1/2] Add `./x.py test rust-analyzer` This adds support for testing `rust-analyzer` in-tree. --- src/bootstrap/builder.rs | 1 + src/bootstrap/test.rs | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 1aa79f5566aa6..d80f7c518958f 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -648,6 +648,7 @@ impl<'a> Builder<'a> { test::Cargotest, test::Cargo, test::Rls, + test::RustAnalyzer, test::ErrorIndex, test::Distcheck, test::RunMakeFullDeps, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 4c6b5ba0afc08..416d262519315 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -352,6 +352,60 @@ impl Step for Rls { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct RustAnalyzer { + stage: u32, + host: TargetSelection, +} + +impl Step for RustAnalyzer { + type Output = (); + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/rust-analyzer") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Self { stage: run.builder.top_stage, host: run.target }); + } + + /// Runs `cargo test` for rust-analyzer. + fn run(self, builder: &Builder<'_>) { + let stage = self.stage; + let host = self.host; + let compiler = builder.compiler(stage, host); + + let build_result = builder.ensure(tool::RustAnalyzer { + compiler, + target: self.host, + extra_features: Vec::new(), + }); + if build_result.is_none() { + eprintln!("failed to test rust-analyzer: could not build"); + return; + } + + let mut cargo = tool::prepare_tool_cargo( + builder, + compiler, + Mode::ToolRustc, + host, + "test", + "src/tools/rust-analyzer", + SourceType::Submodule, + &[], + ); + + cargo.add_rustc_lib_path(builder, compiler); + cargo.arg("--").args(builder.config.cmd.test_args()); + + if try_run(builder, &mut cargo.into()) { + builder.save_toolstate("rust-analyzer", ToolState::TestPass); + } + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt { stage: u32, From b26e89718cbebedb65870fe513c9ef6e62fb064e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 18 Jul 2022 18:20:28 -0700 Subject: [PATCH 2/2] Test rust-analyzer in CI --- src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh b/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh index 412efe5c4480d..c42f00b1f6877 100755 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh @@ -15,6 +15,7 @@ python3 "$X_PY" test --stage 2 --no-fail-fast \ src/doc/embedded-book \ src/doc/edition-guide \ src/tools/rls \ + src/tools/rust-analyzer \ src/tools/miri \ set -e