@@ -8,7 +8,9 @@ use clap::CommandFactory;
88use serde:: Deserialize ;
99
1010use super :: flags:: Flags ;
11- use super :: { ChangeIdWrapper , Config } ;
11+ use super :: {
12+ ChangeIdWrapper , Config , RUSTC_IF_UNCHANGED_ALLOWED_PATHS , RUSTC_IF_UNCHANGED_DENIED_SUBPATHS ,
13+ } ;
1214use crate :: core:: build_steps:: clippy:: get_clippy_rules_in_order;
1315use crate :: core:: build_steps:: llvm;
1416use crate :: core:: config:: { LldMode , Target , TargetSelection , TomlConfig } ;
@@ -352,3 +354,30 @@ fn parse_rust_std_features_empty() {
352354fn parse_rust_std_features_invalid ( ) {
353355 parse ( "rust.std-features = \" backtrace\" " ) ;
354356}
357+
358+ #[ test]
359+ fn check_rustc_if_unchaged_paths ( ) {
360+ let config = parse ( "" ) ;
361+ let normalised_allowed_paths: Vec < _ > = RUSTC_IF_UNCHANGED_ALLOWED_PATHS
362+ . iter ( )
363+ . map ( |t| {
364+ t. strip_prefix ( ":!" ) . expect ( & format ! ( "{t} doesn't have ':!' prefix, but it should." ) )
365+ } )
366+ . collect ( ) ;
367+
368+ let check_existence = |paths| {
369+ for p in paths {
370+ assert ! ( config. src. join( p) . exists( ) , "{p} doesn't exist." ) ;
371+ }
372+ } ;
373+
374+ check_existence ( normalised_allowed_paths. as_slice ( ) ) ;
375+ check_existence ( RUSTC_IF_UNCHANGED_DENIED_SUBPATHS ) ;
376+
377+ for p in RUSTC_IF_UNCHANGED_DENIED_SUBPATHS {
378+ assert ! (
379+ normalised_allowed_paths. iter( ) . any( |t| p. starts_with( t) ) ,
380+ "{p} is not a subpath of an allowed path, there is no need to keep it in the denied list."
381+ ) ;
382+ }
383+ }
0 commit comments