Skip to content

Commit 8dd3608

Browse files
committed
tests: update test for runnables
1 parent c565d5b commit 8dd3608

File tree

1 file changed

+99
-0
lines changed
  • crates/rust-analyzer/tests/slow-tests

1 file changed

+99
-0
lines changed

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ fn main() {}
260260
"executableArgs": ["test_eggs", "--exact", "--show-output"],
261261
"cargoExtraArgs": [],
262262
"overrideCargo": null,
263+
"cwd": server.path().join("foo"),
263264
"workspaceRoot": server.path().join("foo")
264265
},
265266
"kind": "cargo",
@@ -279,6 +280,7 @@ fn main() {}
279280
{
280281
"args": {
281282
"overrideCargo": null,
283+
"cwd": server.path().join("foo"),
282284
"workspaceRoot": server.path().join("foo"),
283285
"cargoArgs": [
284286
"test",
@@ -325,6 +327,7 @@ fn main() {}
325327
"executableArgs": [],
326328
"cargoExtraArgs": [],
327329
"overrideCargo": null,
330+
"cwd": server.path().join("foo"),
328331
"workspaceRoot": server.path().join("foo")
329332
},
330333
"kind": "cargo",
@@ -336,6 +339,7 @@ fn main() {}
336339
"executableArgs": [],
337340
"cargoExtraArgs": [],
338341
"overrideCargo": null,
342+
"cwd": server.path().join("foo"),
339343
"workspaceRoot": server.path().join("foo")
340344
},
341345
"kind": "cargo",
@@ -415,6 +419,7 @@ mod tests {
415419
"args": {
416420
"overrideCargo": null,
417421
"workspaceRoot": server.path().join(runnable),
422+
"cwd": server.path().join(runnable),
418423
"cargoArgs": [
419424
"test",
420425
"--package",
@@ -432,6 +437,100 @@ mod tests {
432437
}
433438
}
434439

440+
// The main fn in packages should be run from the workspace root
441+
#[test]
442+
fn test_runnables_cwd() {
443+
if skip_slow_tests() {
444+
return;
445+
}
446+
447+
let server = Project::with_fixture(
448+
r#"
449+
//- /foo/Cargo.toml
450+
[workspace]
451+
members = ["mainpkg", "otherpkg"]
452+
453+
//- /foo/mainpkg/Cargo.toml
454+
[package]
455+
name = "mainpkg"
456+
version = "0.1.0"
457+
458+
//- /foo/mainpkg/src/main.rs
459+
fn main() {}
460+
461+
//- /foo/otherpkg/Cargo.toml
462+
[package]
463+
name = "otherpkg"
464+
version = "0.1.0"
465+
466+
//- /foo/otherpkg/src/lib.rs
467+
#[test]
468+
fn otherpkg() {}
469+
"#,
470+
)
471+
.root("foo")
472+
.server()
473+
.wait_until_workspace_is_loaded();
474+
475+
server.request::<Runnables>(
476+
RunnablesParams {
477+
text_document: server.doc_id("foo/mainpkg/src/main.rs"),
478+
position: None,
479+
},
480+
json!([
481+
"{...}",
482+
{
483+
"label": "cargo test -p mainpkg --all-targets",
484+
"kind": "cargo",
485+
"args": {
486+
"overrideCargo": null,
487+
"workspaceRoot": server.path().join("foo"),
488+
"cwd": server.path().join("foo"),
489+
"cargoArgs": [
490+
"test",
491+
"--package",
492+
"mainpkg",
493+
"--all-targets"
494+
],
495+
"cargoExtraArgs": [],
496+
"executableArgs": []
497+
},
498+
},
499+
"{...}",
500+
"{...}"
501+
]),
502+
);
503+
504+
server.request::<Runnables>(
505+
RunnablesParams {
506+
text_document: server.doc_id("foo/otherpkg/src/lib.rs"),
507+
position: None,
508+
},
509+
json!([
510+
"{...}",
511+
{
512+
"label": "cargo test -p otherpkg --all-targets",
513+
"kind": "cargo",
514+
"args": {
515+
"overrideCargo": null,
516+
"workspaceRoot": server.path().join("foo"),
517+
"cwd": server.path().join("foo").join("otherpkg"),
518+
"cargoArgs": [
519+
"test",
520+
"--package",
521+
"otherpkg",
522+
"--all-targets"
523+
],
524+
"cargoExtraArgs": [],
525+
"executableArgs": []
526+
},
527+
},
528+
"{...}",
529+
"{...}"
530+
]),
531+
);
532+
}
533+
435534
#[test]
436535
fn test_format_document() {
437536
if skip_slow_tests() {

0 commit comments

Comments
 (0)