@@ -212,6 +212,55 @@ fn alias_and_path_for_library() {
212
212
assert_eq ! ( first( cache. all:: <doc:: Std >( ) ) , & [ doc_std!( A => A , stage = 0 ) ] ) ;
213
213
}
214
214
215
+ #[ test]
216
+ fn ci_rustc_if_unchanged_logic ( ) {
217
+ let config = Config :: parse_inner (
218
+ Flags :: parse ( & [
219
+ "build" . to_owned ( ) ,
220
+ "--dry-run" . to_owned ( ) ,
221
+ "--set=rust.download-rustc='if-unchanged'" . to_owned ( ) ,
222
+ ] ) ,
223
+ |& _| Ok ( Default :: default ( ) ) ,
224
+ ) ;
225
+
226
+ let build = Build :: new ( config. clone ( ) ) ;
227
+ let builder = Builder :: new ( & build) ;
228
+
229
+ if config. rust_info . is_from_tarball ( ) {
230
+ return ;
231
+ }
232
+
233
+ if config. out . exists ( ) {
234
+ fs:: remove_dir_all ( & config. out ) . unwrap ( ) ;
235
+ }
236
+
237
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( config. cmd . kind ( ) ) , & [ ] ) ;
238
+
239
+ let commit = helpers:: get_closest_merge_base_commit (
240
+ Some ( & builder. config . src ) ,
241
+ & builder. config . git_config ( ) ,
242
+ & builder. config . stage0_metadata . config . git_merge_commit_email ,
243
+ & [ ] ,
244
+ )
245
+ . unwrap ( ) ;
246
+
247
+ let compiler_path = build. src . join ( "compiler" ) ;
248
+ let library_path = build. src . join ( "library" ) ;
249
+
250
+ let has_changes = helpers:: git ( Some ( & builder. src ) )
251
+ . args ( [ "diff-index" , "--quiet" , & commit] )
252
+ . arg ( "--" )
253
+ . args ( [ compiler_path, library_path] )
254
+ . as_command_mut ( )
255
+ . status ( )
256
+ . unwrap ( )
257
+ . success ( ) ;
258
+
259
+ assert ! (
260
+ has_changes != config. out. join( config. build. to_string( ) ) . join( "ci-rustc-sysroot" ) . exists( )
261
+ ) ;
262
+ }
263
+
215
264
mod defaults {
216
265
use pretty_assertions:: assert_eq;
217
266
0 commit comments