Skip to content

Commit f9a4d05

Browse files
committed
Auto merge of rust-lang#16845 - HKalbasi:test-explorer, r=HKalbasi
Show compilation progress in test explorer Fix part of rust-lang#16827
2 parents d763e05 + eeff20d commit f9a4d05

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

crates/flycheck/src/test_runner.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ pub enum CargoTestMessage {
2828
},
2929
Suite,
3030
Finished,
31+
Custom {
32+
text: String,
33+
},
3134
}
3235

3336
impl ParseFromLine for CargoTestMessage {
34-
fn from_line(line: &str, error: &mut String) -> Option<Self> {
37+
fn from_line(line: &str, _: &mut String) -> Option<Self> {
3538
let mut deserializer = serde_json::Deserializer::from_str(line);
3639
deserializer.disable_recursion_limit();
3740
if let Ok(message) = CargoTestMessage::deserialize(&mut deserializer) {
3841
return Some(message);
3942
}
4043

41-
error.push_str(line);
42-
error.push('\n');
43-
None
44+
Some(CargoTestMessage::Custom { text: line.to_owned() })
4445
}
4546

4647
fn from_eof() -> Option<Self> {

crates/rust-analyzer/src/lsp/ext.rs

+7
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ impl Notification for EndRunTest {
234234
const METHOD: &'static str = "experimental/endRunTest";
235235
}
236236

237+
pub enum AppendOutputToRunTest {}
238+
239+
impl Notification for AppendOutputToRunTest {
240+
type Params = String;
241+
const METHOD: &'static str = "experimental/appendOutputToRunTest";
242+
}
243+
237244
pub enum AbortRunTest {}
238245

239246
impl Notification for AbortRunTest {

crates/rust-analyzer/src/main_loop.rs

+3
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,9 @@ impl GlobalState {
799799
self.send_notification::<lsp_ext::EndRunTest>(());
800800
self.test_run_session = None;
801801
}
802+
flycheck::CargoTestMessage::Custom { text } => {
803+
self.send_notification::<lsp_ext::AppendOutputToRunTest>(text);
804+
}
802805
}
803806
}
804807

docs/dev/lsp-extensions.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!---
2-
lsp/ext.rs hash: 6bc140531b403717
2+
lsp/ext.rs hash: 61f485497d6e8e88
33
44
If you need to change the above hash to make the test pass, please check if you
55
need to adjust this doc as well and ping this issue:
@@ -509,6 +509,13 @@ interface ChangeTestStateParams {
509509
}
510510
```
511511

512+
**Method:** `experimental/appendOutputToRunTest`
513+
514+
**Notification:** `string`
515+
516+
This notification is used for reporting messages independent of any single test and related to the run session
517+
in general, e.g. cargo compiling progress messages or warnings.
518+
512519
## Open External Documentation
513520

514521
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.

editors/code/src/lsp_ext.ts

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ export const discoveredTests = new lc.NotificationType<DiscoverTestResults>(
100100
export const runTest = new lc.RequestType<RunTestParams, void, void>("experimental/runTest");
101101
export const abortRunTest = new lc.NotificationType0("experimental/abortRunTest");
102102
export const endRunTest = new lc.NotificationType0("experimental/endRunTest");
103+
export const appendOutputToRunTest = new lc.NotificationType<string>(
104+
"experimental/appendOutputToRunTest",
105+
);
103106
export const changeTestState = new lc.NotificationType<ChangeTestStateParams>(
104107
"experimental/changeTestState",
105108
);

editors/code/src/test_explorer.ts

+6
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ export const prepareTestExplorer = (
141141
}),
142142
);
143143

144+
ctx.pushClientCleanup(
145+
client.onNotification(ra.appendOutputToRunTest, (output) => {
146+
currentTestRun!.appendOutput(`${output}\r\n`);
147+
}),
148+
);
149+
144150
ctx.pushClientCleanup(
145151
client.onNotification(ra.changeTestState, (results) => {
146152
const test = idToTestMap.get(results.testId)!;

0 commit comments

Comments
 (0)