@@ -1085,3 +1085,33 @@ fn test_is_builder_target() {
10851085 assert ! ( !builder. is_builder_target( target2) ) ;
10861086 }
10871087}
1088+
1089+ #[ test]
1090+ fn test_get_tool_rustc_compiler ( ) {
1091+ let mut config = configure ( "build" , & [ ] , & [ ] ) ;
1092+ config. download_rustc_commit = None ;
1093+ let build = Build :: new ( config) ;
1094+ let builder = Builder :: new ( & build) ;
1095+
1096+ let target_triple_1 = TargetSelection :: from_user ( TEST_TRIPLE_1 ) ;
1097+
1098+ let compiler = Compiler { stage : 2 , host : target_triple_1 } ;
1099+ let expected = Compiler { stage : 1 , host : target_triple_1 } ;
1100+ let actual = tool:: get_tool_rustc_compiler ( & builder, compiler) ;
1101+ assert_eq ! ( expected, actual) ;
1102+
1103+ let compiler = Compiler { stage : 1 , host : target_triple_1 } ;
1104+ let expected = Compiler { stage : 0 , host : target_triple_1 } ;
1105+ let actual = tool:: get_tool_rustc_compiler ( & builder, compiler) ;
1106+ assert_eq ! ( expected, actual) ;
1107+
1108+ let mut config = configure ( "build" , & [ ] , & [ ] ) ;
1109+ config. download_rustc_commit = Some ( "" . to_owned ( ) ) ;
1110+ let build = Build :: new ( config) ;
1111+ let builder = Builder :: new ( & build) ;
1112+
1113+ let compiler = Compiler { stage : 1 , host : target_triple_1 } ;
1114+ let expected = Compiler { stage : 1 , host : target_triple_1 } ;
1115+ let actual = tool:: get_tool_rustc_compiler ( & builder, compiler) ;
1116+ assert_eq ! ( expected, actual) ;
1117+ }
0 commit comments