@@ -3,8 +3,8 @@ use std::io::Write;
3
3
use std:: path:: PathBuf ;
4
4
5
5
use crate :: utils:: helpers:: {
6
- check_cfg_arg, extract_beta_rev, hex_encode, make , program_out_of_date , set_file_times ,
7
- symlink_dir,
6
+ check_cfg_arg, extract_beta_rev, hex_encode, is_path_in_submodule , make , program_out_of_date ,
7
+ set_file_times , symlink_dir,
8
8
} ;
9
9
use crate :: { Config , Flags } ;
10
10
@@ -115,3 +115,18 @@ fn test_set_file_times_sanity_check() {
115
115
assert_eq ! ( found_metadata. accessed( ) . unwrap( ) , unix_epoch) ;
116
116
assert_eq ! ( found_metadata. modified( ) . unwrap( ) , unix_epoch)
117
117
}
118
+
119
+ #[ test]
120
+ fn test_is_path_in_submodule ( ) {
121
+ let config = Config :: parse_inner ( Flags :: parse ( & [ "build" . into ( ) , "--dry-run" . into ( ) ] ) , |& _| {
122
+ Ok ( Default :: default ( ) )
123
+ } ) ;
124
+
125
+ let build = crate :: Build :: new ( config. clone ( ) ) ;
126
+ let builder = crate :: core:: builder:: Builder :: new ( & build) ;
127
+ assert ! ( !is_path_in_submodule( & builder, "invalid/path" ) ) ;
128
+ assert ! ( is_path_in_submodule( & builder, "src/tools/cargo" ) ) ;
129
+ assert ! ( is_path_in_submodule( & builder, "src/llvm-project" ) ) ;
130
+ // Make sure subdirs are handled properly
131
+ assert ! ( is_path_in_submodule( & builder, "src/tools/cargo/random-subdir" ) ) ;
132
+ }
0 commit comments