about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/flycheck/src/test_runner.rs9
-rw-r--r--crates/rust-analyzer/src/lsp/ext.rs7
-rw-r--r--crates/rust-analyzer/src/main_loop.rs3
-rw-r--r--docs/dev/lsp-extensions.md9
-rw-r--r--editors/code/src/lsp_ext.ts3
-rw-r--r--editors/code/src/test_explorer.ts6
6 files changed, 32 insertions, 5 deletions
diff --git a/crates/flycheck/src/test_runner.rs b/crates/flycheck/src/test_runner.rs
index 6dac5899ee3..31378716b3e 100644
--- a/crates/flycheck/src/test_runner.rs
+++ b/crates/flycheck/src/test_runner.rs
@@ -28,19 +28,20 @@ pub enum CargoTestMessage {
     },
     Suite,
     Finished,
+    Custom {
+        text: String,
+    },
 }
 
 impl ParseFromLine for CargoTestMessage {
-    fn from_line(line: &str, error: &mut String) -> Option<Self> {
+    fn from_line(line: &str, _: &mut String) -> Option<Self> {
         let mut deserializer = serde_json::Deserializer::from_str(line);
         deserializer.disable_recursion_limit();
         if let Ok(message) = CargoTestMessage::deserialize(&mut deserializer) {
             return Some(message);
         }
 
-        error.push_str(line);
-        error.push('\n');
-        None
+        Some(CargoTestMessage::Custom { text: line.to_owned() })
     }
 
     fn from_eof() -> Option<Self> {
diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs
index 86ab652f8ef..710ce7f8acb 100644
--- a/crates/rust-analyzer/src/lsp/ext.rs
+++ b/crates/rust-analyzer/src/lsp/ext.rs
@@ -234,6 +234,13 @@ impl Notification for EndRunTest {
     const METHOD: &'static str = "experimental/endRunTest";
 }
 
+pub enum AppendOutputToRunTest {}
+
+impl Notification for AppendOutputToRunTest {
+    type Params = String;
+    const METHOD: &'static str = "experimental/appendOutputToRunTest";
+}
+
 pub enum AbortRunTest {}
 
 impl Notification for AbortRunTest {
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e106a85c6eb..ffe56e41435 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -799,6 +799,9 @@ impl GlobalState {
                 self.send_notification::<lsp_ext::EndRunTest>(());
                 self.test_run_session = None;
             }
+            flycheck::CargoTestMessage::Custom { text } => {
+                self.send_notification::<lsp_ext::AppendOutputToRunTest>(text);
+            }
         }
     }
 
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index af5b4e51ef3..cf9ad5fe04d 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -1,5 +1,5 @@
 <!---
-lsp/ext.rs hash: 6bc140531b403717
+lsp/ext.rs hash: 61f485497d6e8e88
 
 If you need to change the above hash to make the test pass, please check if you
 need to adjust this doc as well and ping this issue:
@@ -509,6 +509,13 @@ interface ChangeTestStateParams {
 }
 ```
 
+**Method:** `experimental/appendOutputToRunTest`
+
+**Notification:** `string`
+
+This notification is used for reporting messages independent of any single test and related to the run session
+in general, e.g. cargo compiling progress messages or warnings.
+
 ## Open External Documentation
 
 This request is sent from the client to the server to obtain web and local URL(s) for documentation related to the symbol under the cursor, if available.
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 31ac3d9413e..ca8106371b0 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -100,6 +100,9 @@ export const discoveredTests = new lc.NotificationType<DiscoverTestResults>(
 export const runTest = new lc.RequestType<RunTestParams, void, void>("experimental/runTest");
 export const abortRunTest = new lc.NotificationType0("experimental/abortRunTest");
 export const endRunTest = new lc.NotificationType0("experimental/endRunTest");
+export const appendOutputToRunTest = new lc.NotificationType<string>(
+    "experimental/appendOutputToRunTest",
+);
 export const changeTestState = new lc.NotificationType<ChangeTestStateParams>(
     "experimental/changeTestState",
 );
diff --git a/editors/code/src/test_explorer.ts b/editors/code/src/test_explorer.ts
index 2f0b4d5b5cf..ac4ffb19263 100644
--- a/editors/code/src/test_explorer.ts
+++ b/editors/code/src/test_explorer.ts
@@ -142,6 +142,12 @@ export const prepareTestExplorer = (
     );
 
     ctx.pushClientCleanup(
+        client.onNotification(ra.appendOutputToRunTest, (output) => {
+            currentTestRun!.appendOutput(`${output}\r\n`);
+        }),
+    );
+
+    ctx.pushClientCleanup(
         client.onNotification(ra.changeTestState, (results) => {
             const test = idToTestMap.get(results.testId)!;
             if (results.state.tag === "failed") {