@@ -340,3 +340,208 @@ fn check_msg_format_json() {
340
340
)
341
341
. run ( ) ;
342
342
}
343
+
344
+ #[ cargo_test]
345
+ fn targets_with_relative_path_in_workspace_members ( ) {
346
+ let p = project ( )
347
+ . file (
348
+ "Cargo.toml" ,
349
+ r#"
350
+ [workspace]
351
+ members = ["relative-bar"]
352
+ resolver = "2"
353
+ "# ,
354
+ )
355
+ . file (
356
+ "relative-bar/Cargo.toml" ,
357
+ r#"
358
+ [package]
359
+ name = "relative-bar"
360
+ version = "0.1.0"
361
+ edition = "2021"
362
+
363
+ build = "./build.rs"
364
+
365
+ [[bin]]
366
+ name = "bar"
367
+ path = "./src/main.rs"
368
+
369
+ [lib]
370
+ name = "lib"
371
+ path = "./src/lib.rs"
372
+
373
+ [[example]]
374
+ name = "example"
375
+ path = "./example.rs"
376
+
377
+ [[test]]
378
+ name = "test"
379
+ path = "./test.rs"
380
+
381
+ [[bench]]
382
+ name = "bench"
383
+ path = "./bench.rs"
384
+ "# ,
385
+ )
386
+ . file ( "relative-bar/build.rs" , "fn main() { let a = 1; }" )
387
+ . file ( "relative-bar/src/main.rs" , "fn main() { let a = 1; }" )
388
+ . file ( "relative-bar/src/lib.rs" , "fn a() {}" )
389
+ . file ( "relative-bar/example.rs" , "fn main() { let a = 1; }" )
390
+ . file (
391
+ "relative-bar/test.rs" ,
392
+ r#"
393
+ fn main() {}
394
+
395
+ #[test]
396
+ fn test_a() { let a = 1; }
397
+ "# ,
398
+ )
399
+ . file (
400
+ "relative-bar/bench.rs" ,
401
+ r#"
402
+ #![feature(test)]
403
+ #[cfg(test)]
404
+ extern crate test;
405
+
406
+ #[bench]
407
+ fn bench_a(_b: &mut test::Bencher) { let a = 1; }
408
+ "# ,
409
+ )
410
+ . build ( ) ;
411
+
412
+ p. cargo ( "check" )
413
+ . with_stderr_data ( str![ [ r#"
414
+ [COMPILING] relative-bar v0.1.0 ([ROOT]/foo/relative-bar)
415
+ [WARNING] unused variable: `a`
416
+ --> relative-bar/./build.rs:1:17
417
+ |
418
+ 1 | fn main() { let a = 1; }
419
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
420
+ |
421
+ = [NOTE] `#[warn(unused_variables)]` on by default
422
+
423
+ [WARNING] `relative-bar` (build script) generated 1 warning
424
+ [WARNING] function `a` is never used
425
+ --> relative-bar/./src/lib.rs:1:4
426
+ |
427
+ 1 | fn a() {}
428
+ | ^
429
+ |
430
+ = [NOTE] `#[warn(dead_code)]` on by default
431
+
432
+ [WARNING] `relative-bar` (lib) generated 1 warning
433
+ [WARNING] unused variable: `a`
434
+ --> relative-bar/./src/main.rs:1:17
435
+ |
436
+ 1 | fn main() { let a = 1; }
437
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
438
+ |
439
+ = [NOTE] `#[warn(unused_variables)]` on by default
440
+
441
+ [WARNING] `relative-bar` (bin "bar") generated 1 warning
442
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
443
+
444
+ "# ] ] )
445
+ . run ( ) ;
446
+
447
+ p. cargo ( "check --example example" )
448
+ . with_stderr_data ( str![ [ r#"
449
+ [WARNING] unused variable: `a`
450
+ --> relative-bar/./build.rs:1:17
451
+ |
452
+ 1 | fn main() { let a = 1; }
453
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
454
+ |
455
+ = [NOTE] `#[warn(unused_variables)]` on by default
456
+
457
+ [WARNING] `relative-bar` (build script) generated 1 warning
458
+ [WARNING] function `a` is never used
459
+ --> relative-bar/./src/lib.rs:1:4
460
+ |
461
+ 1 | fn a() {}
462
+ | ^
463
+ |
464
+ = [NOTE] `#[warn(dead_code)]` on by default
465
+
466
+ [WARNING] `relative-bar` (lib) generated 1 warning
467
+ [CHECKING] relative-bar v0.1.0 ([ROOT]/foo/relative-bar)
468
+ [WARNING] unused variable: `a`
469
+ --> relative-bar/./example.rs:1:17
470
+ |
471
+ 1 | fn main() { let a = 1; }
472
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
473
+ |
474
+ = [NOTE] `#[warn(unused_variables)]` on by default
475
+
476
+ [WARNING] `relative-bar` (example "example") generated 1 warning
477
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
478
+
479
+ "# ] ] )
480
+ . run ( ) ;
481
+
482
+ p. cargo ( "check --test test" ) . with_stderr_data ( str![ [ r#"
483
+ [WARNING] unused variable: `a`
484
+ --> relative-bar/./build.rs:1:17
485
+ |
486
+ 1 | fn main() { let a = 1; }
487
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
488
+ |
489
+ = [NOTE] `#[warn(unused_variables)]` on by default
490
+
491
+ [WARNING] `relative-bar` (build script) generated 1 warning
492
+ [WARNING] function `a` is never used
493
+ --> relative-bar/./src/lib.rs:1:4
494
+ |
495
+ 1 | fn a() {}
496
+ | ^
497
+ |
498
+ = [NOTE] `#[warn(dead_code)]` on by default
499
+
500
+ [WARNING] `relative-bar` (lib) generated 1 warning
501
+ [CHECKING] relative-bar v0.1.0 ([ROOT]/foo/relative-bar)
502
+ [WARNING] unused variable: `a`
503
+ --> relative-bar/./test.rs:5:35
504
+ |
505
+ 5 | fn test_a() { let a = 1; }
506
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
507
+ |
508
+ = [NOTE] `#[warn(unused_variables)]` on by default
509
+
510
+ [WARNING] `relative-bar` (test "test") generated 1 warning
511
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
512
+
513
+ "# ] ] ) . run ( ) ;
514
+
515
+ p. cargo ( "check --bench bench" ) . with_stderr_data ( str![ [ r#"
516
+ [WARNING] unused variable: `a`
517
+ --> relative-bar/./build.rs:1:17
518
+ |
519
+ 1 | fn main() { let a = 1; }
520
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
521
+ |
522
+ = [NOTE] `#[warn(unused_variables)]` on by default
523
+
524
+ [WARNING] `relative-bar` (build script) generated 1 warning
525
+ [WARNING] function `a` is never used
526
+ --> relative-bar/./src/lib.rs:1:4
527
+ |
528
+ 1 | fn a() {}
529
+ | ^
530
+ |
531
+ = [NOTE] `#[warn(dead_code)]` on by default
532
+
533
+ [WARNING] `relative-bar` (lib) generated 1 warning
534
+ [CHECKING] relative-bar v0.1.0 ([ROOT]/foo/relative-bar)
535
+ [WARNING] unused variable: `a`
536
+ --> relative-bar/./bench.rs:7:58
537
+ |
538
+ 7 | fn bench_a(_b: &mut test::Bencher) { let a = 1; }
539
+ | ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
540
+ |
541
+ = [NOTE] `#[warn(unused_variables)]` on by default
542
+
543
+ [WARNING] `relative-bar` (bench "bench") generated 1 warning
544
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
545
+
546
+ "# ] ] ) . run ( ) ;
547
+ }
0 commit comments