@@ -2065,3 +2065,53 @@ warning: If you meant to build software to target that platform, perhaps try `ru
2065
2065
) ;
2066
2066
} ) ;
2067
2067
}
2068
+
2069
+ /// Checks that `rust-toolchain.toml` files are considered
2070
+ #[ test]
2071
+ fn rust_toolchain_toml ( ) {
2072
+ setup ( & |config| {
2073
+ let cwd = config. current_dir ( ) ;
2074
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
2075
+ raw:: write_file ( & toolchain_file, "[toolchain]\n channel = \" nightly\" " ) . unwrap ( ) ;
2076
+
2077
+ expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "hash-nightly-2" ) ;
2078
+ } ) ;
2079
+ }
2080
+
2081
+ /// Ensures that `rust-toolchain.toml` files (with `.toml` extension) only allow TOML contents
2082
+ #[ test]
2083
+ fn only_toml_in_rust_toolchain_toml ( ) {
2084
+ setup ( & |config| {
2085
+ let cwd = config. current_dir ( ) ;
2086
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
2087
+ raw:: write_file ( & toolchain_file, "nightly" ) . unwrap ( ) ;
2088
+
2089
+ expect_err (
2090
+ config,
2091
+ & [ "rustc" , "--version" ] ,
2092
+ "error parsing override file" ,
2093
+ ) ;
2094
+ } ) ;
2095
+ }
2096
+
2097
+ /// Checks that a warning occurs if both `rust-toolchain` and `rust-toolchain.toml` files exist
2098
+ #[ test]
2099
+ fn warn_on_duplicate_rust_toolchain_file ( ) {
2100
+ setup ( & |config| {
2101
+ let cwd = config. current_dir ( ) ;
2102
+ let toolchain_file_1 = cwd. join ( "rust-toolchain" ) ;
2103
+ raw:: write_file ( & toolchain_file_1, "stable" ) . unwrap ( ) ;
2104
+ let toolchain_file_2 = cwd. join ( "rust-toolchain.toml" ) ;
2105
+ raw:: write_file ( & toolchain_file_2, "[toolchain]" ) . unwrap ( ) ;
2106
+
2107
+ expect_stderr_ok (
2108
+ config,
2109
+ & [ "rustc" , "--version" ] ,
2110
+ & format ! (
2111
+ "warning: both `{0}` and `{1}` exist. Using `{0}`" ,
2112
+ toolchain_file_1. display( ) ,
2113
+ toolchain_file_2. display( ) ,
2114
+ ) ,
2115
+ ) ;
2116
+ } ) ;
2117
+ }
0 commit comments