diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-19 23:46:06 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-24 01:15:57 +0200 |
commit | b688da8189f69a760d140400f3f19bd188754b57 (patch) | |
tree | c3a1c205507b1ccb6eccb54e3d321d95894eac8c /pkgs/test | |
parent | 9a0ef886236eefb13ea84422c5c8ba7865ccf6f8 (diff) |
tests.nixpkgs-check-by-name: Intermediate WrongCallPackage 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 | 16 |
2 files changed, 17 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 4f1ee9f674f62..6b1d120de8fab 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 { + WrongCallPackage { + relative_package_file: PathBuf, + package_name: String, + }, NonDerivation { relative_package_file: PathBuf, package_name: String, @@ -60,6 +64,12 @@ impl CheckError { impl fmt::Display for CheckError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + CheckError::WrongCallPackage { relative_package_file, package_name } => + write!( + f, + "pkgs.{package_name}: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage {} {{ ... }}` with a non-empty second argument.", + relative_package_file.display() + ), CheckError::NonDerivation { 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 695d52c0a8f29..d1c5135b7d85f 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/eval.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/eval.rs @@ -137,15 +137,13 @@ pub fn check_values<W: io::Write>( AttributeVariant::Other => false, }; - if !valid { - error_writer.write(&format!( - "pkgs.{package_name}: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage {} {{ ... }}` with a non-empty second argument.", - relative_package_file.display() - ))?; - continue; - } - - let check_result = if !attribute_info.is_derivation { + let check_result = if !valid { + CheckError::WrongCallPackage { + relative_package_file: relative_package_file.clone(), + package_name: package_name.clone(), + } + .into_result() + } else if !attribute_info.is_derivation { CheckError::NonDerivation { relative_package_file: relative_package_file.clone(), package_name: package_name.clone(), |