@@ -549,6 +549,51 @@ fn fallback_cargo_calls_correct_rustc() {
549
549
} ) ;
550
550
}
551
551
552
+ // Checks that cargo can recursively invoke itself with rustup shorthand (via
553
+ // the proxy).
554
+ //
555
+ // This involves a series of chained commands:
556
+ //
557
+ // 1. Calls `cargo --recursive-cargo-subcommand`
558
+ // 2. The rustup `cargo` proxy launches, and launches the "mock" nightly cargo exe.
559
+ // 3. The nightly "mock" cargo sees --recursive-cargo-subcommand, and launches
560
+ // `cargo-foo --recursive-cargo`
561
+ // 4. `cargo-foo` sees `--recursive-cargo` and launches `cargo +nightly --version`
562
+ // 5. The rustup `cargo` proxy launches, and launches the "mock" nightly cargo exe.
563
+ // 6. The nightly "mock" cargo sees `--version` and prints the version.
564
+ //
565
+ // Previously, rustup would place the toolchain's `bin` directory in PATH for
566
+ // Windows due to some DLL issues. However, those aren't necessary anymore.
567
+ // If the toolchain `bin` directory is in PATH, then this test would fail in
568
+ // step 5 because the `cargo` executable would be the "mock" nightly cargo,
569
+ // and the first argument would be `+nightly` which would be an error.
570
+ #[ test]
571
+ fn recursive_cargo ( ) {
572
+ setup ( & |config| {
573
+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
574
+
575
+ // We need an intermediary to run cargo itself.
576
+ // The "mock" cargo can't do that because on Windows it will check
577
+ // for a `cargo.exe` in the current directory before checking PATH.
578
+ //
579
+ // The solution here is to copy from the "mock" `cargo.exe` into
580
+ // `~/.cargo/bin/cargo-foo`. This is just for convenience to avoid
581
+ // needing to build another executable just for this test.
582
+ let output = clitools:: run ( config, "rustup" , & [ "which" , "cargo" ] , & [ ] ) ;
583
+ let real_mock_cargo = output. stdout . trim ( ) ;
584
+ let cargo_bin_path = config. cargodir . join ( "bin" ) ;
585
+ let cargo_subcommand = cargo_bin_path. join ( format ! ( "cargo-foo{}" , EXE_SUFFIX ) ) ;
586
+ fs:: create_dir_all ( & cargo_bin_path) . unwrap ( ) ;
587
+ fs:: copy ( & real_mock_cargo, & cargo_subcommand) . unwrap ( ) ;
588
+
589
+ expect_stdout_ok (
590
+ config,
591
+ & [ "cargo" , "--recursive-cargo-subcommand" ] ,
592
+ "hash-nightly-2" ,
593
+ ) ;
594
+ } ) ;
595
+ }
596
+
552
597
#[ test]
553
598
fn show_home ( ) {
554
599
setup ( & |config| {
0 commit comments