diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-20 00:30:18 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-24 01:15:57 +0200 |
commit | b011d53bda903f70d884ca42a43b65db9b430901 (patch) | |
tree | 1b4f541cfb7fff6e5704e1480a6377e50b81153d /pkgs/test | |
parent | 64f5eb616e673babd2b54cc07394b04b22242493 (diff) |
tests.nixpkgs-check-by-name: Intermediate IncorrectShard error
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/check_result.rs | 11 | ||||
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/structure.rs | 25 |
2 files changed, 27 insertions, 9 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/src/check_result.rs b/pkgs/test/nixpkgs-check-by-name/src/check_result.rs index 882ad8c8e2ca3..e42652039c2c0 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/check_result.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/check_result.rs @@ -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, diff --git a/pkgs/test/nixpkgs-check-by-name/src/structure.rs b/pkgs/test/nixpkgs-check-by-name/src/structure.rs index 5a60dc26954b0..8dc9ca61940af 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/structure.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/structure.rs @@ -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()); |