tests: update test for runnables · rust-lang/rust@3c7a13d
@@ -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,94 @@ mod tests {
432437}
433438}
434439440+// 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 { text_document: server.doc_id("foo/mainpkg/src/main.rs"), position: None },
477+json!([
478+"{...}",
479+{
480+"label": "cargo test -p mainpkg --all-targets",
481+"kind": "cargo",
482+"args": {
483+"overrideCargo": null,
484+"workspaceRoot": server.path().join("foo"),
485+"cwd": server.path().join("foo"),
486+"cargoArgs": [
487+"test",
488+"--package",
489+"mainpkg",
490+"--all-targets"
491+],
492+"cargoExtraArgs": [],
493+"executableArgs": []
494+},
495+},
496+"{...}",
497+"{...}"
498+]),
499+);
500+501+ server.request::<Runnables>(
502+RunnablesParams { text_document: server.doc_id("foo/otherpkg/src/lib.rs"), position: None },
503+json!([
504+"{...}",
505+{
506+"label": "cargo test -p otherpkg --all-targets",
507+"kind": "cargo",
508+"args": {
509+"overrideCargo": null,
510+"workspaceRoot": server.path().join("foo"),
511+"cwd": server.path().join("foo").join("otherpkg"),
512+"cargoArgs": [
513+"test",
514+"--package",
515+"otherpkg",
516+"--all-targets"
517+],
518+"cargoExtraArgs": [],
519+"executableArgs": []
520+},
521+},
522+"{...}",
523+"{...}"
524+]),
525+);
526+}
527+435528#[test]
436529fn test_format_document() {
437530if skip_slow_tests() {