diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-20 00:10:29 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-24 01:15:57 +0200 |
commit | 64f5eb616e673babd2b54cc07394b04b22242493 (patch) | |
tree | ff490521ea370f601fa5eeb93f4fc5964d7207a2 /pkgs/test | |
parent | e3979d14cda13b4a6cb15ebccf6052cc67c0db4c (diff) |
tests.nixpkgs-check-by-name: Intermediate PackageNixNonExistent error
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/check_result.rs | 9 | ||||
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/structure.rs | 23 |
2 files changed, 22 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 13d780cfd56e9..882ad8c8e2ca3 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,9 @@ use std::io; use std::path::PathBuf; pub enum CheckError { + PackageNixNonExistent { + relative_package_dir: PathBuf, + }, PackageNixDir { relative_package_dir: PathBuf, }, @@ -72,6 +75,12 @@ impl CheckError { impl fmt::Display for CheckError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + CheckError::PackageNixNonExistent { relative_package_dir } => + write!( + f, + "{}: Missing required \"{PACKAGE_NIX_FILENAME}\" file.", + relative_package_dir.display(), + ), CheckError::PackageNixDir { 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 928d5ea088ec3..5a60dc26954b0 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::{write_check_result, CheckError}; +use crate::check_result::{pass, write_check_result, CheckError}; use crate::utils; use crate::utils::{ErrorWriter, BASE_SUBPATH, PACKAGE_NIX_FILENAME}; use lazy_static::lazy_static; @@ -126,18 +126,21 @@ impl Nixpkgs { } let package_nix_path = package_path.join(PACKAGE_NIX_FILENAME); - if !package_nix_path.exists() { - error_writer.write(&format!( - "{}: Missing required \"{PACKAGE_NIX_FILENAME}\" file.", - relative_package_dir.display(), - ))?; + let check_result = if !package_nix_path.exists() { + CheckError::PackageNixNonExistent { + relative_package_dir: relative_package_dir.clone(), + } + .into_result() } else if package_nix_path.is_dir() { - let check_result = CheckError::PackageNixDir { + CheckError::PackageNixDir { relative_package_dir: relative_package_dir.clone(), } - .into_result::<()>(); - write_check_result(error_writer, check_result)?; - } + .into_result() + } else { + pass(()) + }; + + write_check_result(error_writer, check_result)?; package_names.push(package_name.clone()); } |