diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-19 23:48:31 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-24 01:15:57 +0200 |
commit | 4f17b9367d7535fc5308557b92e1b306662b3d3d (patch) | |
tree | a6014686766333e41e1a8b572988fd738af589e2 /pkgs/test | |
parent | b688da8189f69a760d140400f3f19bd188754b57 (diff) |
tests.nixpkgs-check-by-name: Intermediate UndefinedAttr error
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/check_result.rs | 10 | ||||
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/eval.rs | 20 |
2 files changed, 20 insertions, 10 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 6b1d120de8fab..f546b12854507 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/check_result.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/check_result.rs @@ -6,6 +6,10 @@ use std::io; use std::path::PathBuf; pub enum CheckError { + UndefinedAttr { + relative_package_file: PathBuf, + package_name: String, + }, WrongCallPackage { relative_package_file: PathBuf, package_name: String, @@ -64,6 +68,12 @@ impl CheckError { impl fmt::Display for CheckError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + CheckError::UndefinedAttr { relative_package_file, package_name } => + write!( + f, + "pkgs.{package_name}: This attribute is not defined but it should be defined automatically as {}", + relative_package_file.display() + ), CheckError::WrongCallPackage { relative_package_file, package_name } => write!( f, diff --git a/pkgs/test/nixpkgs-check-by-name/src/eval.rs b/pkgs/test/nixpkgs-check-by-name/src/eval.rs index d1c5135b7d85f..81cf43a381ed3 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/eval.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/eval.rs @@ -116,7 +116,7 @@ pub fn check_values<W: io::Write>( let relative_package_file = structure::Nixpkgs::relative_file_for_package(package_name); let absolute_package_file = nixpkgs.path.join(&relative_package_file); - if let Some(attribute_info) = actual_files.get(package_name) { + let check_result = if let Some(attribute_info) = actual_files.get(package_name) { let valid = match &attribute_info.variant { AttributeVariant::AutoCalled => true, AttributeVariant::CallPackage { path, empty_arg } => { @@ -137,7 +137,7 @@ pub fn check_values<W: io::Write>( AttributeVariant::Other => false, }; - let check_result = if !valid { + if !valid { CheckError::WrongCallPackage { relative_package_file: relative_package_file.clone(), package_name: package_name.clone(), @@ -151,15 +151,15 @@ pub fn check_values<W: io::Write>( .into_result() } else { pass(()) - }; - write_check_result(error_writer, check_result)?; + } } else { - error_writer.write(&format!( - "pkgs.{package_name}: This attribute is not defined but it should be defined automatically as {}", - relative_package_file.display() - ))?; - continue; - } + CheckError::UndefinedAttr { + relative_package_file: relative_package_file.clone(), + package_name: package_name.clone(), + } + .into_result() + }; + write_check_result(error_writer, check_result)?; } Ok(()) } |