Skip to content

Commit dd0c978

Browse files
committed
Fix tests
1 parent a83ab82 commit dd0c978

File tree

2 files changed

+60
-54
lines changed

2 files changed

+60
-54
lines changed

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ pub enum RunnableKind {
139139
#[derive(Deserialize, Serialize, Debug)]
140140
#[serde(rename_all = "camelCase")]
141141
pub struct CargoRunnable {
142+
#[serde(skip_serializing_if = "Option::is_none")]
142143
pub workspace_root: Option<PathBuf>,
143144
// command, --package and --lib stuff
144145
pub cargo_args: Vec<String>,

crates/rust-analyzer/tests/heavy_tests/main.rs

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,33 @@ fn foo() {
7676
server.request::<Runnables>(
7777
RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
7878
json!([
79-
{
80-
"args": [ "test" ],
81-
"extraArgs": [ "foo", "--nocapture" ],
82-
"kind": "cargo",
83-
"env": { "RUST_BACKTRACE": "short" },
84-
"cwd": null,
85-
"label": "test foo",
86-
"range": {
87-
"end": { "character": 1, "line": 2 },
88-
"start": { "character": 0, "line": 0 }
89-
}
90-
},
91-
{
92-
"args": ["check", "--workspace"],
93-
"extraArgs": [],
94-
"kind": "cargo",
95-
"env": {},
96-
"cwd": null,
97-
"label": "cargo check --workspace",
98-
"range": {
99-
"end": { "character": 0, "line": 0 },
100-
"start": { "character": 0, "line": 0 }
79+
{
80+
"args": {
81+
"cargoArgs": ["test"],
82+
"executableArgs": ["foo", "--nocapture"],
83+
},
84+
"kind": "cargo",
85+
"label": "test foo",
86+
"location": {
87+
"targetRange": {
88+
"end": { "character": 1, "line": 2 },
89+
"start": { "character": 0, "line": 0 }
90+
},
91+
"targetSelectionRange": {
92+
"end": { "character": 6, "line": 1 },
93+
"start": { "character": 3, "line": 1 }
94+
},
95+
"targetUri": "file:///[..]/lib.rs"
96+
}
97+
},
98+
{
99+
"args": {
100+
"cargoArgs": ["check", "--workspace"],
101+
"executableArgs": [],
102+
},
103+
"kind": "cargo",
104+
"label": "cargo check --workspace"
101105
}
102-
}
103106
]),
104107
);
105108
}
@@ -138,42 +141,44 @@ fn main() {}
138141
server.request::<Runnables>(
139142
RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
140143
json!([
141-
{
142-
"args": [ "test", "--package", "foo", "--test", "spam" ],
143-
"extraArgs": [ "test_eggs", "--exact", "--nocapture" ],
144-
"kind": "cargo",
145-
"env": { "RUST_BACKTRACE": "short" },
146-
"label": "test test_eggs",
147-
"range": {
148-
"end": { "character": 17, "line": 1 },
149-
"start": { "character": 0, "line": 0 }
150-
},
151-
"cwd": server.path().join("foo")
144+
{
145+
"args": {
146+
"cargoArgs": ["test", "--package", "foo", "--test", "spam"],
147+
"executableArgs": ["test_eggs", "--exact", "--nocapture"],
148+
"workspaceRoot": server.path().join("foo")
152149
},
153-
{
154-
"args": [ "check", "--package", "foo" ],
155-
"extraArgs": [],
156-
"kind": "cargo",
157-
"env": {},
158-
"label": "cargo check -p foo",
159-
"range": {
160-
"end": { "character": 0, "line": 0 },
150+
"kind": "cargo",
151+
"label": "test test_eggs",
152+
"location": {
153+
"targetRange": {
154+
"end": { "character": 17, "line": 1 },
161155
"start": { "character": 0, "line": 0 }
162156
},
163-
"cwd": server.path().join("foo")
164-
},
165-
{
166-
"args": [ "test", "--package", "foo" ],
167-
"extraArgs": [],
168-
"kind": "cargo",
169-
"env": {},
170-
"label": "cargo test -p foo",
171-
"range": {
172-
"end": { "character": 0, "line": 0 },
173-
"start": { "character": 0, "line": 0 }
157+
"targetSelectionRange": {
158+
"end": { "character": 12, "line": 1 },
159+
"start": { "character": 3, "line": 1 }
174160
},
175-
"cwd": server.path().join("foo")
161+
"targetUri": "file:///[..]/tests/spam.rs"
176162
}
163+
},
164+
{
165+
"args": {
166+
"cargoArgs": ["check", "--package", "foo"],
167+
"executableArgs": [],
168+
"workspaceRoot": server.path().join("foo")
169+
},
170+
"kind": "cargo",
171+
"label": "cargo check -p foo"
172+
},
173+
{
174+
"args": {
175+
"cargoArgs": ["test", "--package", "foo"],
176+
"executableArgs": [],
177+
"workspaceRoot": server.path().join("foo")
178+
},
179+
"kind": "cargo",
180+
"label": "cargo test -p foo"
181+
}
177182
]),
178183
);
179184
}

0 commit comments

Comments
 (0)