Skip to content

Commit c52435a

Browse files
committed
cleanup and fix naming
1 parent 414eb48 commit c52435a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/bootstrap/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
157157
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
158158
}
159159
if !check && paths.is_empty() {
160-
match get_modified_rs_files(&build) {
160+
match get_modified_rs_files(build) {
161161
Ok(Some(files)) => {
162162
for file in files {
163163
println!("formatting modified file {file}");

src/tools/compiletest/src/main.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
525525
pub fn make_tests(config: &Config, tests: &mut Vec<test::TestDescAndFn>) {
526526
debug!("making tests from {:?}", config.src_base.display());
527527
let inputs = common_inputs_stamp(config);
528-
let modified_tests = modified_tests(config, &config.src_base);
528+
let modified_tests = modified_tests(config, &config.src_base).unwrap_or_else(|err| {
529+
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
530+
});
529531
collect_tests_from_dir(
530532
config,
531533
&config.src_base,
@@ -573,13 +575,14 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
573575
stamp
574576
}
575577

576-
fn modified_tests(config: &Config, dir: &Path) -> Vec<PathBuf> {
578+
fn modified_tests(config: &Config, dir: &Path) -> Result<Vec<PathBuf>, String> {
577579
if !config.only_modified {
578-
return vec![];
580+
return Ok(vec![]);
579581
}
580-
let Ok(Some(files)) = get_git_modified_files(Some(dir), &vec!["rs", "stderr", "fixed"]) else { return vec![]; };
582+
let files =
583+
get_git_modified_files(Some(dir), &vec!["rs", "stderr", "fixed"])?.unwrap_or(vec![]);
581584
// Add new test cases to the list, it will be convenient in daily development.
582-
let Ok(Some(untracked_files)) = get_git_untracked_files(None) else { return vec![]; };
585+
let untracked_files = get_git_untracked_files(None)?.unwrap_or(vec![]);
583586

584587
let all_paths = [&files[..], &untracked_files[..]].concat();
585588
let full_paths = {
@@ -591,7 +594,7 @@ fn modified_tests(config: &Config, dir: &Path) -> Vec<PathBuf> {
591594
full_paths.sort_unstable();
592595
full_paths
593596
};
594-
full_paths
597+
Ok(full_paths)
595598
}
596599

597600
fn collect_tests_from_dir(
@@ -600,7 +603,7 @@ fn collect_tests_from_dir(
600603
relative_dir_path: &Path,
601604
inputs: &Stamp,
602605
tests: &mut Vec<test::TestDescAndFn>,
603-
only_modified: &Vec<PathBuf>,
606+
modified_tests: &Vec<PathBuf>,
604607
) -> io::Result<()> {
605608
// Ignore directories that contain a file named `compiletest-ignore-dir`.
606609
if dir.join("compiletest-ignore-dir").exists() {
@@ -631,7 +634,7 @@ fn collect_tests_from_dir(
631634
let file = file?;
632635
let file_path = file.path();
633636
let file_name = file.file_name();
634-
if is_test(&file_name) && (!config.only_modified || only_modified.contains(&file_path)) {
637+
if is_test(&file_name) && (!config.only_modified || modified_tests.contains(&file_path)) {
635638
debug!("found test file: {:?}", file_path.display());
636639
let paths =
637640
TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
@@ -647,7 +650,7 @@ fn collect_tests_from_dir(
647650
&relative_file_path,
648651
inputs,
649652
tests,
650-
only_modified,
653+
modified_tests,
651654
)?;
652655
}
653656
} else {

0 commit comments

Comments
 (0)