tests.nixpkgs-check-by-name: Intermediate IncorrectShard error
This commit is contained in:
parent
64f5eb616e
commit
b011d53bda
2 changed files with 27 additions and 9 deletions
|
@ -7,6 +7,10 @@ use std::io;
|
|||
use std::path::PathBuf;
|
||||
|
||||
pub enum CheckError {
|
||||
IncorrectShard {
|
||||
relative_package_dir: PathBuf,
|
||||
correct_relative_package_dir: PathBuf,
|
||||
},
|
||||
PackageNixNonExistent {
|
||||
relative_package_dir: PathBuf,
|
||||
},
|
||||
|
@ -75,6 +79,13 @@ impl CheckError {
|
|||
impl fmt::Display for CheckError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CheckError::IncorrectShard { relative_package_dir, correct_relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Incorrect directory location, should be {} instead.",
|
||||
relative_package_dir.display(),
|
||||
correct_relative_package_dir.display(),
|
||||
),
|
||||
CheckError::PackageNixNonExistent { relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::check_result::{pass, write_check_result, CheckError};
|
||||
use crate::check_result::{flatten_check_results, pass, write_check_result, CheckError};
|
||||
use crate::utils;
|
||||
use crate::utils::{ErrorWriter, BASE_SUBPATH, PACKAGE_NIX_FILENAME};
|
||||
use lazy_static::lazy_static;
|
||||
|
@ -113,20 +113,24 @@ impl Nixpkgs {
|
|||
}
|
||||
|
||||
let correct_relative_package_dir = Nixpkgs::relative_dir_for_package(&package_name);
|
||||
if relative_package_dir != correct_relative_package_dir {
|
||||
let shard_check_result = if relative_package_dir != correct_relative_package_dir {
|
||||
// Only show this error if we have a valid shard and package name
|
||||
// Because if one of those is wrong, you should fix that first
|
||||
if shard_name_valid && package_name_valid {
|
||||
error_writer.write(&format!(
|
||||
"{}: Incorrect directory location, should be {} instead.",
|
||||
relative_package_dir.display(),
|
||||
correct_relative_package_dir.display(),
|
||||
))?;
|
||||
CheckError::IncorrectShard {
|
||||
relative_package_dir: relative_package_dir.clone(),
|
||||
correct_relative_package_dir: correct_relative_package_dir.clone(),
|
||||
}
|
||||
.into_result()
|
||||
} else {
|
||||
pass(())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pass(())
|
||||
};
|
||||
|
||||
let package_nix_path = package_path.join(PACKAGE_NIX_FILENAME);
|
||||
let check_result = if !package_nix_path.exists() {
|
||||
let package_nix_check_result = if !package_nix_path.exists() {
|
||||
CheckError::PackageNixNonExistent {
|
||||
relative_package_dir: relative_package_dir.clone(),
|
||||
}
|
||||
|
@ -140,6 +144,9 @@ impl Nixpkgs {
|
|||
pass(())
|
||||
};
|
||||
|
||||
let check_result =
|
||||
flatten_check_results([shard_check_result, package_nix_check_result], |_| ());
|
||||
|
||||
write_check_result(error_writer, check_result)?;
|
||||
|
||||
package_names.push(package_name.clone());
|
||||
|
|
Loading…
Reference in a new issue