about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-12 01:51:21 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-12 02:28:09 +0200
commit23541bed72c8385acddfc8e7ba0bd15d5a2c26af (patch)
treee0c9b48f18033bf7b309ec55a0ffadfc83f57d68 /pkgs/test
parentfcaa408d005743b34aed8b7e2992ef885b4ce027 (diff)
tests.nixpkgs-check-by-name: Introduce --version
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/nixpkgs-check-by-name/README.md6
-rw-r--r--pkgs/test/nixpkgs-check-by-name/src/main.rs22
2 files changed, 24 insertions, 4 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/README.md b/pkgs/test/nixpkgs-check-by-name/README.md
index 4dd694acd2f0a..ebd1cd40aba08 100644
--- a/pkgs/test/nixpkgs-check-by-name/README.md
+++ b/pkgs/test/nixpkgs-check-by-name/README.md
@@ -11,6 +11,12 @@ This API may be changed over time if the CI workflow making use of it is adjuste
 - Command line: `nixpkgs-check-by-name <NIXPKGS>`
 - Arguments:
   - `<NIXPKGS>`: The path to the Nixpkgs to check
+  - `--version <VERSION>`: The version of the checks to perform.
+
+    Possible values:
+    - `v0` (default)
+
+    See [validation](#validity-checks) for the differences.
 - Exit code:
   - `0`: If the [validation](#validity-checks) is successful
   - `1`: If the [validation](#validity-checks) is not successful
diff --git a/pkgs/test/nixpkgs-check-by-name/src/main.rs b/pkgs/test/nixpkgs-check-by-name/src/main.rs
index 8c663061bb097..5c51f32b5cec9 100644
--- a/pkgs/test/nixpkgs-check-by-name/src/main.rs
+++ b/pkgs/test/nixpkgs-check-by-name/src/main.rs
@@ -4,7 +4,7 @@ mod structure;
 mod utils;
 
 use anyhow::Context;
-use clap::Parser;
+use clap::{Parser, ValueEnum};
 use colored::Colorize;
 use std::io;
 use std::path::{Path, PathBuf};
@@ -15,14 +15,26 @@ use utils::ErrorWriter;
 /// Program to check the validity of pkgs/by-name
 #[derive(Parser, Debug)]
 #[command(about)]
-struct Args {
+pub struct Args {
     /// Path to nixpkgs
     nixpkgs: PathBuf,
+    /// The version of the checks
+    /// Increasing this may cause failures for a Nixpkgs that succeeded before
+    /// TODO: Remove default once Nixpkgs CI passes this argument
+    #[arg(long, value_enum, default_value_t = Version::V0)]
+    version: Version,
+}
+
+/// The version of the checks
+#[derive(Debug, Clone, PartialEq, PartialOrd, ValueEnum)]
+pub enum Version {
+    /// Initial version
+    V0,
 }
 
 fn main() -> ExitCode {
     let args = Args::parse();
-    match check_nixpkgs(&args.nixpkgs, vec![], &mut io::stderr()) {
+    match check_nixpkgs(&args.nixpkgs, args.version, vec![], &mut io::stderr()) {
         Ok(true) => {
             eprintln!("{}", "Validated successfully".green());
             ExitCode::SUCCESS
@@ -53,6 +65,7 @@ fn main() -> ExitCode {
 /// - `Ok(true)` if the structure is valid, nothing will have been written to `error_writer`.
 pub fn check_nixpkgs<W: io::Write>(
     nixpkgs_path: &Path,
+    _version: Version,
     eval_accessible_paths: Vec<&Path>,
     error_writer: &mut W,
 ) -> anyhow::Result<bool> {
@@ -86,6 +99,7 @@ pub fn check_nixpkgs<W: io::Write>(
 mod tests {
     use crate::check_nixpkgs;
     use crate::structure;
+    use crate::Version;
     use anyhow::Context;
     use std::fs;
     use std::path::Path;
@@ -174,7 +188,7 @@ mod tests {
         // We don't want coloring to mess up the tests
         let writer = temp_env::with_var("NO_COLOR", Some("1"), || -> anyhow::Result<_> {
             let mut writer = vec![];
-            check_nixpkgs(&path, vec![&extra_nix_path], &mut writer)
+            check_nixpkgs(&path, Version::V0, vec![&extra_nix_path], &mut writer)
                 .context(format!("Failed test case {name}"))?;
             Ok(writer)
         })?;