@@ -8,7 +8,9 @@ use clap::CommandFactory;
8
8
use serde:: Deserialize ;
9
9
10
10
use 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
+ } ;
12
14
use crate :: core:: build_steps:: clippy:: get_clippy_rules_in_order;
13
15
use crate :: core:: build_steps:: llvm;
14
16
use crate :: core:: config:: { LldMode , Target , TargetSelection , TomlConfig } ;
@@ -352,3 +354,30 @@ fn parse_rust_std_features_empty() {
352
354
fn parse_rust_std_features_invalid ( ) {
353
355
parse ( "rust.std-features = \" backtrace\" " ) ;
354
356
}
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