Skip to content

Commit

Permalink
add test coverage for helpers::is_path_in_submodule
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Dec 31, 2024
1 parent b1b576d commit 6eb9ebf
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/bootstrap/src/utils/helpers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::io::Write;
use std::path::PathBuf;

use crate::utils::helpers::{
check_cfg_arg, extract_beta_rev, hex_encode, make, program_out_of_date, set_file_times,
symlink_dir,
check_cfg_arg, extract_beta_rev, hex_encode, is_path_in_submodule, make, program_out_of_date,
set_file_times, symlink_dir,
};
use crate::{Config, Flags};

Expand Down Expand Up @@ -115,3 +115,18 @@ fn test_set_file_times_sanity_check() {
assert_eq!(found_metadata.accessed().unwrap(), unix_epoch);
assert_eq!(found_metadata.modified().unwrap(), unix_epoch)
}

#[test]
fn test_is_path_in_submodule() {
let config = Config::parse_inner(Flags::parse(&["build".into(), "--dry-run".into()]), |&_| {
Ok(Default::default())
});

let build = crate::Build::new(config.clone());
let builder = crate::core::builder::Builder::new(&build);
assert!(!is_path_in_submodule(&builder, "invalid/path"));
assert!(is_path_in_submodule(&builder, "src/tools/cargo"));
assert!(is_path_in_submodule(&builder, "src/llvm-project"));
// Make sure subdirs are handled properly
assert!(is_path_in_submodule(&builder, "src/tools/cargo/random-subdir"));
}

0 comments on commit 6eb9ebf

Please sign in to comment.