diff options
| -rw-r--r-- | crates/flycheck/src/test_runner.rs | 1 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/lsp/ext.rs | 4 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/lsp/to_proto.rs | 8 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 1 | ||||
| -rw-r--r-- | docs/dev/lsp-extensions.md | 31 | ||||
| -rw-r--r-- | editors/code/src/lsp_ext.ts | 9 | ||||
| -rw-r--r-- | editors/code/src/test_explorer.ts | 6 |
7 files changed, 45 insertions, 15 deletions
diff --git a/crates/flycheck/src/test_runner.rs b/crates/flycheck/src/test_runner.rs index b7d966989b9..6dac5899ee3 100644 --- a/crates/flycheck/src/test_runner.rs +++ b/crates/flycheck/src/test_runner.rs @@ -14,6 +14,7 @@ use crate::command::{CommandHandle, ParseFromLine}; pub enum TestState { Started, Ok, + Ignored, Failed { stdout: String }, } diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs index 842e765d9d1..86ab652f8ef 100644 --- a/crates/rust-analyzer/src/lsp/ext.rs +++ b/crates/rust-analyzer/src/lsp/ext.rs @@ -171,7 +171,7 @@ pub struct DiscoverTestParams { #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub enum TestItemIcon { +pub enum TestItemKind { Package, Module, Test, @@ -182,7 +182,7 @@ pub enum TestItemIcon { pub struct TestItem { pub id: String, pub label: String, - pub icon: TestItemIcon, + pub kind: TestItemKind, pub can_resolve_children: bool, pub parent: Option<String>, pub text_document: Option<TextDocumentIdentifier>, diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index f0bb7d8af3a..e2b55f4a5c5 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -1506,10 +1506,10 @@ pub(crate) fn test_item( lsp_ext::TestItem { id: test_item.id, label: test_item.label, - icon: match test_item.kind { - ide::TestItemKind::Crate => lsp_ext::TestItemIcon::Package, - ide::TestItemKind::Module => lsp_ext::TestItemIcon::Module, - ide::TestItemKind::Function => lsp_ext::TestItemIcon::Test, + kind: match test_item.kind { + ide::TestItemKind::Crate => lsp_ext::TestItemKind::Package, + ide::TestItemKind::Module => lsp_ext::TestItemKind::Module, + ide::TestItemKind::Function => lsp_ext::TestItemKind::Test, }, can_resolve_children: matches!( test_item.kind, diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 99c00d0384a..bca6db19dcf 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -779,6 +779,7 @@ impl GlobalState { flycheck::CargoTestMessage::Test { name, state } => { let state = match state { flycheck::TestState::Started => lsp_ext::TestState::Started, + flycheck::TestState::Ignored => lsp_ext::TestState::Skipped, flycheck::TestState::Ok => lsp_ext::TestState::Passed, flycheck::TestState::Failed { stdout } => { lsp_ext::TestState::Failed { message: stdout } diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 17e2eb5da5c..af5b4e51ef3 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@ <!--- -lsp/ext.rs hash: 4b06686d086b7d9b +lsp/ext.rs hash: 6bc140531b403717 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: @@ -416,7 +416,9 @@ interface TestItem { range?: lc.Range | undefined; // A human readable name for this test label: string; - icon: "package" | "module" | "test"; + // The kind of this test item. Based on the kind, + // an icon is chosen by the editor. + kind: "package" | "module" | "test"; // True if this test may have children not available eagerly canResolveChildren: boolean; // The id of the parent test in the test tree. If not present, this test @@ -425,6 +427,10 @@ interface TestItem { // The information useful for running the test. The client can use `runTest` // request for simple execution, but for more complex execution forms // like debugging, this field is useful. + // Note that this field includes some information about label and location as well, but + // those exist just for keeping things in sync with other methods of running runnables + // (for example using one consistent name in the vscode's launch.json) so for any propose + // other than running tests this field should not be used. runnable?: Runnable | undefined; }; @@ -451,8 +457,14 @@ the same as the one in `experimental/discoverTest` response. **Request:** `RunTestParams` ```typescript -interface DiscoverTestParams { +interface RunTestParams { + // Id of the tests to be run. If a test is included, all of its children are included implicitly. If + // this property is undefined, then the server should simply run all tests. include?: string[] | undefined; + // An array of test ids the user has marked as excluded from the test included in this run; exclusions + // should apply after inclusions. + // May be omitted if no exclusions were requested. Server should not run excluded tests or + // any children of excluded tests. exclude?: string[] | undefined; } ``` @@ -480,9 +492,16 @@ a `experimental/endRunTest` when is done. **Notification:** `ChangeTestStateParams` ```typescript -type TestState = { tag: "failed"; message: string } - | { tag: "passed" } - | { tag: "started" }; +type TestState = { tag: "passed" } + | { + tag: "failed"; + // The standard error of the test, containing the panic message. Clients should + // render it similar to a terminal, and e.g. handle ansi colors. + message: string; + } + | { tag: "started" } + | { tag: "enqueued" } + | { tag: "skipped" }; interface ChangeTestStateParams { testId: string; diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index acbc5cbeaef..31ac3d9413e 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -76,7 +76,7 @@ export type RunTestParams = { export type TestItem = { id: string; label: string; - icon: "package" | "module" | "test"; + kind: "package" | "module" | "test"; canResolveChildren: boolean; parent?: string | undefined; textDocument?: lc.TextDocumentIdentifier | undefined; @@ -84,7 +84,12 @@ export type TestItem = { runnable?: Runnable | undefined; }; export type DiscoverTestResults = { tests: TestItem[]; scope: string[] }; -export type TestState = { tag: "failed"; message: string } | { tag: "passed" } | { tag: "started" }; +export type TestState = + | { tag: "failed"; message: string } + | { tag: "passed" } + | { tag: "started" } + | { tag: "enqueued" } + | { tag: "skipped" }; export type ChangeTestStateParams = { testId: string; state: TestState }; export const discoverTest = new lc.RequestType<DiscoverTestParams, DiscoverTestResults, void>( "experimental/discoverTest", diff --git a/editors/code/src/test_explorer.ts b/editors/code/src/test_explorer.ts index e89a5cfc391..2f0b4d5b5cf 100644 --- a/editors/code/src/test_explorer.ts +++ b/editors/code/src/test_explorer.ts @@ -85,7 +85,7 @@ export const prepareTestExplorer = ( }; const test = testController.createTestItem( item.id, - `$(${iconToVscodeMap[item.icon]}) ${item.label}`, + `$(${iconToVscodeMap[item.kind]}) ${item.label}`, uri, ); test.range = range; @@ -150,6 +150,10 @@ export const prepareTestExplorer = ( currentTestRun!.passed(test); } else if (results.state.tag === "started") { currentTestRun!.started(test); + } else if (results.state.tag === "skipped") { + currentTestRun!.skipped(test); + } else if (results.state.tag === "enqueued") { + currentTestRun!.enqueued(test); } }), ); |
