tests.nixpkgs-check-by-name: Refactor
This commit is contained in:
parent
571eaed155
commit
bb89ca72df
@ -49,19 +49,17 @@ impl Nixpkgs {
|
||||
) -> anyhow::Result<Nixpkgs> {
|
||||
let base_dir = path.join(BASE_SUBPATH);
|
||||
|
||||
let mut package_names = Vec::new();
|
||||
|
||||
for shard_entry in utils::read_dir_sorted(&base_dir)? {
|
||||
let check_results = utils::read_dir_sorted(&base_dir)?
|
||||
.into_iter()
|
||||
.map(|shard_entry| {
|
||||
let shard_path = shard_entry.path();
|
||||
let shard_name = shard_entry.file_name().to_string_lossy().into_owned();
|
||||
let relative_shard_path = Nixpkgs::relative_dir_for_shard(&shard_name);
|
||||
|
||||
if shard_name == "README.md" {
|
||||
// README.md is allowed to be a file and not checked
|
||||
continue;
|
||||
}
|
||||
|
||||
let check_result = if !shard_path.is_dir() {
|
||||
pass(vec![])
|
||||
} else if !shard_path.is_dir() {
|
||||
CheckError::ShardNonDir {
|
||||
relative_shard_path: relative_shard_path.clone(),
|
||||
}
|
||||
@ -98,7 +96,8 @@ impl Nixpkgs {
|
||||
.into_result::<()>()
|
||||
});
|
||||
|
||||
let duplicate_check_result = flatten_check_results(duplicate_check_results, |_| ());
|
||||
let duplicate_check_result =
|
||||
flatten_check_results(duplicate_check_results, |_| ());
|
||||
|
||||
write_check_result(error_writer, duplicate_check_result)?;
|
||||
|
||||
@ -134,8 +133,8 @@ impl Nixpkgs {
|
||||
if shard_name_valid && package_name_valid {
|
||||
CheckError::IncorrectShard {
|
||||
relative_package_dir: relative_package_dir.clone(),
|
||||
correct_relative_package_dir: correct_relative_package_dir
|
||||
.clone(),
|
||||
correct_relative_package_dir:
|
||||
correct_relative_package_dir.clone(),
|
||||
}
|
||||
.into_result()
|
||||
} else {
|
||||
@ -172,16 +171,23 @@ impl Nixpkgs {
|
||||
});
|
||||
|
||||
flatten_check_results(check_results, |x| x)
|
||||
};
|
||||
|
||||
if let Some(shard_package_names) = write_check_result(error_writer, check_result)? {
|
||||
package_names.extend(shard_package_names)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let check_result = flatten_check_results(check_results, |x| {
|
||||
x.into_iter().flatten().collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
if let Some(package_names) = write_check_result(error_writer, check_result)? {
|
||||
Ok(Nixpkgs {
|
||||
path: path.to_owned(),
|
||||
package_names,
|
||||
})
|
||||
} else {
|
||||
Ok(Nixpkgs {
|
||||
path: path.to_owned(),
|
||||
package_names: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user