@@ -2065,3 +2065,59 @@ 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
+ expect_err (
2074
+ config,
2075
+ & [ "rustc" , "--version" ] ,
2076
+ "no override and no default toolchain set" ,
2077
+ ) ;
2078
+
2079
+ let cwd = config. current_dir ( ) ;
2080
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
2081
+ raw:: write_file ( & toolchain_file, "[toolchain]\n channel = \" nightly\" " ) . unwrap ( ) ;
2082
+
2083
+ expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "hash-nightly-2" ) ;
2084
+ } ) ;
2085
+ }
2086
+
2087
+ /// Ensures that `rust-toolchain.toml` files (with `.toml` extension) only allow TOML contents
2088
+ #[ test]
2089
+ fn only_toml_in_rust_toolchain_toml ( ) {
2090
+ setup ( & |config| {
2091
+ let cwd = config. current_dir ( ) ;
2092
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
2093
+ raw:: write_file ( & toolchain_file, "nightly" ) . unwrap ( ) ;
2094
+
2095
+ expect_err (
2096
+ config,
2097
+ & [ "rustc" , "--version" ] ,
2098
+ "error parsing override file" ,
2099
+ ) ;
2100
+ } ) ;
2101
+ }
2102
+
2103
+ /// Checks that a warning occurs if both `rust-toolchain` and `rust-toolchain.toml` files exist
2104
+ #[ test]
2105
+ fn warn_on_duplicate_rust_toolchain_file ( ) {
2106
+ setup ( & |config| {
2107
+ let cwd = config. current_dir ( ) ;
2108
+ let toolchain_file_1 = cwd. join ( "rust-toolchain" ) ;
2109
+ raw:: write_file ( & toolchain_file_1, "stable" ) . unwrap ( ) ;
2110
+ let toolchain_file_2 = cwd. join ( "rust-toolchain.toml" ) ;
2111
+ raw:: write_file ( & toolchain_file_2, "[toolchain]" ) . unwrap ( ) ;
2112
+
2113
+ expect_stderr_ok (
2114
+ config,
2115
+ & [ "rustc" , "--version" ] ,
2116
+ & format ! (
2117
+ "warning: both `{0}` and `{1}` exist. Using `{0}`" ,
2118
+ toolchain_file_1. canonicalize( ) . unwrap( ) . display( ) ,
2119
+ toolchain_file_2. canonicalize( ) . unwrap( ) . display( ) ,
2120
+ ) ,
2121
+ ) ;
2122
+ } ) ;
2123
+ }
0 commit comments