@@ -12,6 +12,7 @@ use cargotest::{is_nightly, rustc_host, sleep_ms};
12
12
use cargotest:: support:: paths:: { CargoPathExt , root} ;
13
13
use cargotest:: support:: { ProjectBuilder } ;
14
14
use cargotest:: support:: { project, execs, main_file, basic_bin_manifest} ;
15
+ use cargotest:: support:: registry:: Package ;
15
16
use hamcrest:: { assert_that, existing_file, is_not} ;
16
17
use tempdir:: TempDir ;
17
18
@@ -2554,3 +2555,103 @@ fn cargo_build_empty_target() {
2554
2555
execs ( ) . with_status ( 101 )
2555
2556
. with_stderr_contains ( "[..] target was empty" ) ) ;
2556
2557
}
2558
+
2559
+ #[ test]
2560
+ fn build_all_workspace ( ) {
2561
+ let p = project ( "foo" )
2562
+ . file ( "Cargo.toml" , r#"
2563
+ [project]
2564
+ name = "foo"
2565
+ version = "0.1.0"
2566
+
2567
+ [dependencies]
2568
+ bar = { path = "bar" }
2569
+
2570
+ [workspace]
2571
+ "# )
2572
+ . file ( "src/main.rs" , r#"
2573
+ fn main() {}
2574
+ "# )
2575
+ . file ( "bar/Cargo.toml" , r#"
2576
+ [project]
2577
+ name = "bar"
2578
+ version = "0.1.0"
2579
+ "# )
2580
+ . file ( "bar/src/lib.rs" , r#"
2581
+ pub fn bar() {}
2582
+ "# ) ;
2583
+ p. build ( ) ;
2584
+
2585
+ assert_that ( p. cargo_process ( "build" )
2586
+ . arg ( "--all" ) ,
2587
+ execs ( ) . with_stderr ( "[..] Compiling bar v0.1.0 ([..])\n \
2588
+ [..] Compiling foo v0.1.0 ([..])\n \
2589
+ [..] Finished debug [unoptimized + debuginfo] target(s) in [..]\n ") ) ;
2590
+ }
2591
+
2592
+ #[ test]
2593
+ fn build_all_virtual_manifest ( ) {
2594
+ let p = project ( "workspace" )
2595
+ . file ( "Cargo.toml" , r#"
2596
+ [workspace]
2597
+ members = ["foo", "bar"]
2598
+ "# )
2599
+ . file ( "foo/Cargo.toml" , r#"
2600
+ [project]
2601
+ name = "foo"
2602
+ version = "0.1.0"
2603
+ "# )
2604
+ . file ( "foo/src/lib.rs" , r#"
2605
+ pub fn foo() {}
2606
+ "# )
2607
+ . file ( "bar/Cargo.toml" , r#"
2608
+ [project]
2609
+ name = "bar"
2610
+ version = "0.1.0"
2611
+ "# )
2612
+ . file ( "bar/src/lib.rs" , r#"
2613
+ pub fn bar() {}
2614
+ "# ) ;
2615
+ p. build ( ) ;
2616
+
2617
+ // The order in which foo and bar are built is not guaranteed
2618
+ assert_that ( p. cargo_process ( "build" )
2619
+ . arg ( "--all" ) ,
2620
+ execs ( ) . with_stderr_contains ( "[..] Compiling bar v0.1.0 ([..])" )
2621
+ . with_stderr_contains ( "[..] Compiling foo v0.1.0 ([..])" )
2622
+ . with_stderr ( "[..] Compiling [..] v0.1.0 ([..])\n \
2623
+ [..] Compiling [..] v0.1.0 ([..])\n \
2624
+ [..] Finished debug [unoptimized + debuginfo] target(s) in [..]\n ") ) ;
2625
+ }
2626
+
2627
+ #[ test]
2628
+ fn build_all_member_dependency_same_name ( ) {
2629
+ let p = project ( "workspace" )
2630
+ . file ( "Cargo.toml" , r#"
2631
+ [workspace]
2632
+ members = ["a"]
2633
+ "# )
2634
+ . file ( "a/Cargo.toml" , r#"
2635
+ [project]
2636
+ name = "a"
2637
+ version = "0.1.0"
2638
+
2639
+ [dependencies]
2640
+ a = "0.1.0"
2641
+ "# )
2642
+ . file ( "a/src/lib.rs" , r#"
2643
+ pub fn a() {}
2644
+ "# ) ;
2645
+ p. build ( ) ;
2646
+
2647
+ Package :: new ( "a" , "0.1.0" ) . publish ( ) ;
2648
+
2649
+ assert_that ( p. cargo_process ( "build" )
2650
+ . arg ( "--all" ) ,
2651
+ execs ( ) . with_stderr ( "[..] Updating registry `[..]`\n \
2652
+ [..] Downloading a v0.1.0 ([..])\n \
2653
+ [..] Compiling a v0.1.0\n \
2654
+ [..] Compiling a v0.1.0 ([..])\n \
2655
+ [..] Finished debug [unoptimized + debuginfo] target(s) in [..]\n ") ) ;
2656
+ }
2657
+
0 commit comments