aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/runnables.rs225
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs1
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs113
3 files changed, 270 insertions, 69 deletions
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index 9239ca61b..f32ce0d22 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -228,12 +228,38 @@ mod tests {
228 @r###" 228 @r###"
229 [ 229 [
230 Runnable { 230 Runnable {
231 range: 1..21, 231 nav: NavigationTarget {
232 file_id: FileId(
233 1,
234 ),
235 full_range: 1..21,
236 name: "main",
237 kind: FN_DEF,
238 focus_range: Some(
239 12..16,
240 ),
241 container_name: None,
242 description: None,
243 docs: None,
244 },
232 kind: Bin, 245 kind: Bin,
233 cfg_exprs: [], 246 cfg_exprs: [],
234 }, 247 },
235 Runnable { 248 Runnable {
236 range: 22..46, 249 nav: NavigationTarget {
250 file_id: FileId(
251 1,
252 ),
253 full_range: 22..46,
254 name: "test_foo",
255 kind: FN_DEF,
256 focus_range: Some(
257 33..41,
258 ),
259 container_name: None,
260 description: None,
261 docs: None,
262 },
237 kind: Test { 263 kind: Test {
238 test_id: Path( 264 test_id: Path(
239 "test_foo", 265 "test_foo",
@@ -245,7 +271,20 @@ mod tests {
245 cfg_exprs: [], 271 cfg_exprs: [],
246 }, 272 },
247 Runnable { 273 Runnable {
248 range: 47..81, 274 nav: NavigationTarget {
275 file_id: FileId(
276 1,
277 ),
278 full_range: 47..81,
279 name: "test_foo",
280 kind: FN_DEF,
281 focus_range: Some(
282 68..76,
283 ),
284 container_name: None,
285 description: None,
286 docs: None,
287 },
249 kind: Test { 288 kind: Test {
250 test_id: Path( 289 test_id: Path(
251 "test_foo", 290 "test_foo",
@@ -280,12 +319,38 @@ mod tests {
280 @r###" 319 @r###"
281 [ 320 [
282 Runnable { 321 Runnable {
283 range: 1..21, 322 nav: NavigationTarget {
323 file_id: FileId(
324 1,
325 ),
326 full_range: 1..21,
327 name: "main",
328 kind: FN_DEF,
329 focus_range: Some(
330 12..16,
331 ),
332 container_name: None,
333 description: None,
334 docs: None,
335 },
284 kind: Bin, 336 kind: Bin,
285 cfg_exprs: [], 337 cfg_exprs: [],
286 }, 338 },
287 Runnable { 339 Runnable {
288 range: 22..64, 340 nav: NavigationTarget {
341 file_id: FileId(
342 1,
343 ),
344 full_range: 22..64,
345 name: "foo",
346 kind: FN_DEF,
347 focus_range: Some(
348 56..59,
349 ),
350 container_name: None,
351 description: None,
352 docs: None,
353 },
289 kind: DocTest { 354 kind: DocTest {
290 test_id: Path( 355 test_id: Path(
291 "foo", 356 "foo",
@@ -320,12 +385,38 @@ mod tests {
320 @r###" 385 @r###"
321 [ 386 [
322 Runnable { 387 Runnable {
323 range: 1..21, 388 nav: NavigationTarget {
389 file_id: FileId(
390 1,
391 ),
392 full_range: 1..21,
393 name: "main",
394 kind: FN_DEF,
395 focus_range: Some(
396 12..16,
397 ),
398 container_name: None,
399 description: None,
400 docs: None,
401 },
324 kind: Bin, 402 kind: Bin,
325 cfg_exprs: [], 403 cfg_exprs: [],
326 }, 404 },
327 Runnable { 405 Runnable {
328 range: 51..105, 406 nav: NavigationTarget {
407 file_id: FileId(
408 1,
409 ),
410 full_range: 51..105,
411 name: "foo",
412 kind: FN_DEF,
413 focus_range: Some(
414 97..100,
415 ),
416 container_name: None,
417 description: None,
418 docs: None,
419 },
329 kind: DocTest { 420 kind: DocTest {
330 test_id: Path( 421 test_id: Path(
331 "Data::foo", 422 "Data::foo",
@@ -355,14 +446,40 @@ mod tests {
355 @r###" 446 @r###"
356 [ 447 [
357 Runnable { 448 Runnable {
358 range: 1..59, 449 nav: NavigationTarget {
450 file_id: FileId(
451 1,
452 ),
453 full_range: 1..59,
454 name: "test_mod",
455 kind: MODULE,
456 focus_range: Some(
457 13..21,
458 ),
459 container_name: None,
460 description: None,
461 docs: None,
462 },
359 kind: TestMod { 463 kind: TestMod {
360 path: "test_mod", 464 path: "test_mod",
361 }, 465 },
362 cfg_exprs: [], 466 cfg_exprs: [],
363 }, 467 },
364 Runnable { 468 Runnable {
365 range: 28..57, 469 nav: NavigationTarget {
470 file_id: FileId(
471 1,
472 ),
473 full_range: 28..57,
474 name: "test_foo1",
475 kind: FN_DEF,
476 focus_range: Some(
477 43..52,
478 ),
479 container_name: None,
480 description: None,
481 docs: None,
482 },
366 kind: Test { 483 kind: Test {
367 test_id: Path( 484 test_id: Path(
368 "test_mod::test_foo1", 485 "test_mod::test_foo1",
@@ -397,14 +514,40 @@ mod tests {
397 @r###" 514 @r###"
398 [ 515 [
399 Runnable { 516 Runnable {
400 range: 23..85, 517 nav: NavigationTarget {
518 file_id: FileId(
519 1,
520 ),
521 full_range: 23..85,
522 name: "test_mod",
523 kind: MODULE,
524 focus_range: Some(
525 27..35,
526 ),
527 container_name: None,
528 description: None,
529 docs: None,
530 },
401 kind: TestMod { 531 kind: TestMod {
402 path: "foo::test_mod", 532 path: "foo::test_mod",
403 }, 533 },
404 cfg_exprs: [], 534 cfg_exprs: [],
405 }, 535 },
406 Runnable { 536 Runnable {
407 range: 46..79, 537 nav: NavigationTarget {
538 file_id: FileId(
539 1,
540 ),
541 full_range: 46..79,
542 name: "test_foo1",
543 kind: FN_DEF,
544 focus_range: Some(
545 65..74,
546 ),
547 container_name: None,
548 description: None,
549 docs: None,
550 },
408 kind: Test { 551 kind: Test {
409 test_id: Path( 552 test_id: Path(
410 "foo::test_mod::test_foo1", 553 "foo::test_mod::test_foo1",
@@ -441,14 +584,40 @@ mod tests {
441 @r###" 584 @r###"
442 [ 585 [
443 Runnable { 586 Runnable {
444 range: 41..115, 587 nav: NavigationTarget {
588 file_id: FileId(
589 1,
590 ),
591 full_range: 41..115,
592 name: "test_mod",
593 kind: MODULE,
594 focus_range: Some(
595 45..53,
596 ),
597 container_name: None,
598 description: None,
599 docs: None,
600 },
445 kind: TestMod { 601 kind: TestMod {
446 path: "foo::bar::test_mod", 602 path: "foo::bar::test_mod",
447 }, 603 },
448 cfg_exprs: [], 604 cfg_exprs: [],
449 }, 605 },
450 Runnable { 606 Runnable {
451 range: 68..105, 607 nav: NavigationTarget {
608 file_id: FileId(
609 1,
610 ),
611 full_range: 68..105,
612 name: "test_foo1",
613 kind: FN_DEF,
614 focus_range: Some(
615 91..100,
616 ),
617 container_name: None,
618 description: None,
619 docs: None,
620 },
452 kind: Test { 621 kind: Test {
453 test_id: Path( 622 test_id: Path(
454 "foo::bar::test_mod::test_foo1", 623 "foo::bar::test_mod::test_foo1",
@@ -480,7 +649,20 @@ mod tests {
480 @r###" 649 @r###"
481 [ 650 [
482 Runnable { 651 Runnable {
483 range: 1..58, 652 nav: NavigationTarget {
653 file_id: FileId(
654 1,
655 ),
656 full_range: 1..58,
657 name: "test_foo1",
658 kind: FN_DEF,
659 focus_range: Some(
660 44..53,
661 ),
662 container_name: None,
663 description: None,
664 docs: None,
665 },
484 kind: Test { 666 kind: Test {
485 test_id: Path( 667 test_id: Path(
486 "test_foo1", 668 "test_foo1",
@@ -517,7 +699,20 @@ mod tests {
517 @r###" 699 @r###"
518 [ 700 [
519 Runnable { 701 Runnable {
520 range: 1..80, 702 nav: NavigationTarget {
703 file_id: FileId(
704 1,
705 ),
706 full_range: 1..80,
707 name: "test_foo1",
708 kind: FN_DEF,
709 focus_range: Some(
710 66..75,
711 ),
712 container_name: None,
713 description: None,
714 docs: None,
715 },
521 kind: Test { 716 kind: Test {
522 test_id: Path( 717 test_id: Path(
523 "test_foo1", 718 "test_foo1",
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index 5fa1eba1c..ec24ce5e0 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -139,6 +139,7 @@ pub enum RunnableKind {
139#[derive(Deserialize, Serialize, Debug)] 139#[derive(Deserialize, Serialize, Debug)]
140#[serde(rename_all = "camelCase")] 140#[serde(rename_all = "camelCase")]
141pub struct CargoRunnable { 141pub struct CargoRunnable {
142 #[serde(skip_serializing_if = "Option::is_none")]
142 pub workspace_root: Option<PathBuf>, 143 pub workspace_root: Option<PathBuf>,
143 // command, --package and --lib stuff 144 // command, --package and --lib stuff
144 pub cargo_args: Vec<String>, 145 pub cargo_args: Vec<String>,
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 8b473ff74..e18f973b8 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -76,30 +76,33 @@ fn foo() {
76 server.request::<Runnables>( 76 server.request::<Runnables>(
77 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, 77 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
78 json!([ 78 json!([
79 { 79 {
80 "args": [ "test" ], 80 "args": {
81 "extraArgs": [ "foo", "--nocapture" ], 81 "cargoArgs": ["test"],
82 "kind": "cargo", 82 "executableArgs": ["foo", "--nocapture"],
83 "env": { "RUST_BACKTRACE": "short" }, 83 },
84 "cwd": null, 84 "kind": "cargo",
85 "label": "test foo", 85 "label": "test foo",
86 "range": { 86 "location": {
87 "end": { "character": 1, "line": 2 }, 87 "targetRange": {
88 "start": { "character": 0, "line": 0 } 88 "end": { "character": 1, "line": 2 },
89 } 89 "start": { "character": 0, "line": 0 }
90 }, 90 },
91 { 91 "targetSelectionRange": {
92 "args": ["check", "--workspace"], 92 "end": { "character": 6, "line": 1 },
93 "extraArgs": [], 93 "start": { "character": 3, "line": 1 }
94 "kind": "cargo", 94 },
95 "env": {}, 95 "targetUri": "file:///[..]/lib.rs"
96 "cwd": null, 96 }
97 "label": "cargo check --workspace", 97 },
98 "range": { 98 {
99 "end": { "character": 0, "line": 0 }, 99 "args": {
100 "start": { "character": 0, "line": 0 } 100 "cargoArgs": ["check", "--workspace"],
101 "executableArgs": [],
102 },
103 "kind": "cargo",
104 "label": "cargo check --workspace"
101 } 105 }
102 }
103 ]), 106 ]),
104 ); 107 );
105} 108}
@@ -138,42 +141,44 @@ fn main() {}
138 server.request::<Runnables>( 141 server.request::<Runnables>(
139 RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None }, 142 RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
140 json!([ 143 json!([
141 { 144 {
142 "args": [ "test", "--package", "foo", "--test", "spam" ], 145 "args": {
143 "extraArgs": [ "test_eggs", "--exact", "--nocapture" ], 146 "cargoArgs": ["test", "--package", "foo", "--test", "spam"],
144 "kind": "cargo", 147 "executableArgs": ["test_eggs", "--exact", "--nocapture"],
145 "env": { "RUST_BACKTRACE": "short" }, 148 "workspaceRoot": server.path().join("foo")
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")
152 }, 149 },
153 { 150 "kind": "cargo",
154 "args": [ "check", "--package", "foo" ], 151 "label": "test test_eggs",
155 "extraArgs": [], 152 "location": {
156 "kind": "cargo", 153 "targetRange": {
157 "env": {}, 154 "end": { "character": 17, "line": 1 },
158 "label": "cargo check -p foo",
159 "range": {
160 "end": { "character": 0, "line": 0 },
161 "start": { "character": 0, "line": 0 } 155 "start": { "character": 0, "line": 0 }
162 }, 156 },
163 "cwd": server.path().join("foo") 157 "targetSelectionRange": {
164 }, 158 "end": { "character": 12, "line": 1 },
165 { 159 "start": { "character": 3, "line": 1 }
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 }
174 }, 160 },
175 "cwd": server.path().join("foo") 161 "targetUri": "file:///[..]/tests/spam.rs"
176 } 162 }
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 }
177 ]), 182 ]),
178 ); 183 );
179} 184}