@@ -3038,6 +3038,88 @@ error: no active toolchain
30383038 . is_ok ( ) ;
30393039}
30403040
3041+ #[ tokio:: test]
3042+ async fn rustup_toolchain_source_cli ( ) {
3043+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
3044+ cx. config
3045+ . expect ( & [ "rustup" , "install" , "nightly" ] )
3046+ . await
3047+ . is_ok ( ) ;
3048+ cx. config
3049+ . expect ( [ "cargo" , "+nightly" , "--echo-rustup-toolchain-source" ] )
3050+ . await
3051+ . with_stderr ( snapbox:: str![ [ r#"
3052+ ...
3053+ cli
3054+
3055+ "# ] ] ) ;
3056+ }
3057+
3058+ #[ tokio:: test]
3059+ async fn rustup_toolchain_source_env ( ) {
3060+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
3061+ cx. config
3062+ . expect_with_env (
3063+ [ "cargo" , "--echo-rustup-toolchain-source" ] ,
3064+ [ ( "RUSTUP_TOOLCHAIN" , "nightly" ) ] ,
3065+ )
3066+ . await
3067+ . with_stderr ( snapbox:: str![ [ r#"
3068+ ...
3069+ env
3070+
3071+ "# ] ] ) ;
3072+ }
3073+
3074+ #[ tokio:: test]
3075+ async fn rustup_toolchain_source_path_override ( ) {
3076+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
3077+ cx. config
3078+ . expect ( [ "rustup" , "override" , "set" , "nightly" ] )
3079+ . await
3080+ . is_ok ( ) ;
3081+ cx. config
3082+ . expect ( [ "cargo" , "--echo-rustup-toolchain-source" ] )
3083+ . await
3084+ . with_stderr ( snapbox:: str![ [ r#"
3085+ ...
3086+ path-override
3087+
3088+ "# ] ] ) ;
3089+ }
3090+
3091+ #[ tokio:: test]
3092+ async fn rustup_toolchain_source_toolchain_file ( ) {
3093+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
3094+ let toolchain_file = cx. config . current_dir ( ) . join ( "rust-toolchain.toml" ) ;
3095+ raw:: write_file ( & toolchain_file, "[toolchain]\n channel='nightly'" ) . unwrap ( ) ;
3096+ cx. config
3097+ . expect ( [ "cargo" , "--echo-rustup-toolchain-source" ] )
3098+ . await
3099+ . with_stderr ( snapbox:: str![ [ r#"
3100+ ...
3101+ toolchain-file
3102+
3103+ "# ] ] ) ;
3104+ }
3105+
3106+ #[ tokio:: test]
3107+ async fn rustup_toolchain_source_default ( ) {
3108+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
3109+ cx. config
3110+ . expect ( & [ "rustup" , "default" , "stable" ] )
3111+ . await
3112+ . is_ok ( ) ;
3113+ cx. config
3114+ . expect ( [ "cargo" , "--echo-rustup-toolchain-source" ] )
3115+ . await
3116+ . with_stderr ( snapbox:: str![ [ r#"
3117+ ...
3118+ default
3119+
3120+ "# ] ] ) ;
3121+ }
3122+
30413123#[ tokio:: test]
30423124async fn directory_override_doesnt_need_to_exist_unless_it_is_selected ( ) {
30433125 let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
0 commit comments