@@ -260,6 +260,7 @@ fn main() {}
260
260
"executableArgs" : [ "test_eggs" , "--exact" , "--show-output" ] ,
261
261
"cargoExtraArgs" : [ ] ,
262
262
"overrideCargo" : null,
263
+ "cwd" : server. path( ) . join( "foo" ) ,
263
264
"workspaceRoot" : server. path( ) . join( "foo" )
264
265
} ,
265
266
"kind" : "cargo" ,
@@ -279,6 +280,7 @@ fn main() {}
279
280
{
280
281
"args" : {
281
282
"overrideCargo" : null,
283
+ "cwd" : server. path( ) . join( "foo" ) ,
282
284
"workspaceRoot" : server. path( ) . join( "foo" ) ,
283
285
"cargoArgs" : [
284
286
"test" ,
@@ -325,6 +327,7 @@ fn main() {}
325
327
"executableArgs" : [ ] ,
326
328
"cargoExtraArgs" : [ ] ,
327
329
"overrideCargo" : null,
330
+ "cwd" : server. path( ) . join( "foo" ) ,
328
331
"workspaceRoot" : server. path( ) . join( "foo" )
329
332
} ,
330
333
"kind" : "cargo" ,
@@ -336,6 +339,7 @@ fn main() {}
336
339
"executableArgs" : [ ] ,
337
340
"cargoExtraArgs" : [ ] ,
338
341
"overrideCargo" : null,
342
+ "cwd" : server. path( ) . join( "foo" ) ,
339
343
"workspaceRoot" : server. path( ) . join( "foo" )
340
344
} ,
341
345
"kind" : "cargo" ,
@@ -415,6 +419,7 @@ mod tests {
415
419
"args" : {
416
420
"overrideCargo" : null,
417
421
"workspaceRoot" : server. path( ) . join( runnable) ,
422
+ "cwd" : server. path( ) . join( runnable) ,
418
423
"cargoArgs" : [
419
424
"test" ,
420
425
"--package" ,
@@ -432,6 +437,100 @@ mod tests {
432
437
}
433
438
}
434
439
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
+
435
534
#[ test]
436
535
fn test_format_document ( ) {
437
536
if skip_slow_tests ( ) {
0 commit comments