about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorAmos Wenger <amoswenger@gmail.com>2022-07-22 17:21:33 +0200
committerAmos Wenger <amoswenger@gmail.com>2022-07-24 10:37:47 +0200
commit4ea2f8e48fb9c69432b59d5f9f90a576cd0845da (patch)
tree5418932f2b5a74264e10ca00d49821203b248139 /src/bootstrap
parentd59abcf9b372548cc1664fb2a2cf34fc900991de (diff)
downloadrust-4ea2f8e48fb9c69432b59d5f9f90a576cd0845da.tar.gz
rust-4ea2f8e48fb9c69432b59d5f9f90a576cd0845da.zip
Add test step for rust-analyzer, run it by default
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs1
-rw-r--r--src/bootstrap/test.rs49
2 files changed, 50 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 74768c8e59e..8876f70c8c6 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -649,6 +649,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 078207d85fe..9578520c429 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -353,6 +353,55 @@ 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;
+    const DEFAULT: 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);
+
+        builder.ensure(tool::RustAnalyzer { compiler, target: self.host }).expect("in-tree tool");
+
+        let path = "src/tools/rust-analyzer";
+        let mut cargo = tool::prepare_tool_cargo(
+            builder,
+            compiler,
+            Mode::ToolStd,
+            host,
+            "test",
+            path,
+            SourceType::InTree,
+            &["rust-analyzer/in-rust-tree".to_owned()],
+        );
+
+        let dir = builder.src.join(path);
+        cargo.env("CARGO_WORKSPACE_DIR", &dir);
+
+        cargo.add_rustc_lib_path(builder, compiler);
+        cargo.arg("--").args(builder.config.cmd.test_args());
+
+        builder.run(&mut cargo.into());
+    }
+}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 pub struct Rustfmt {
     stage: u32,
     host: TargetSelection,