diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-11-21 16:12:21 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-11-21 16:12:48 +0100 |
commit | 048a4cd441a59cbf89defb18bb45c9f0b4429b35 (patch) | |
tree | f8f5850ff05521ab82d65745894714a8796cbfb6 /pkgs/test/nixpkgs-check-by-name/src/utils.rs | |
parent | 030c5028b07afcedce7c5956015c629486cc79d9 (diff) | |
parent | 4c2d05dd6435d449a3651a6dd314d9411b5f8146 (diff) | |
download | nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.gz nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.bz2 nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.lz nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.xz nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.zst nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.zip |
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Diffstat (limited to 'pkgs/test/nixpkgs-check-by-name/src/utils.rs')
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/utils.rs | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/src/utils.rs b/pkgs/test/nixpkgs-check-by-name/src/utils.rs index 325c736eca9..5cc4a0863ba 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/utils.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/utils.rs @@ -1,9 +1,11 @@ use anyhow::Context; -use colored::Colorize; use std::fs; use std::io; use std::path::Path; +pub const BASE_SUBPATH: &str = "pkgs/by-name"; +pub const PACKAGE_NIX_FILENAME: &str = "package.nix"; + /// Deterministic file listing so that tests are reproducible pub fn read_dir_sorted(base_dir: &Path) -> anyhow::Result<Vec<fs::DirEntry>> { let listing = base_dir @@ -47,26 +49,3 @@ impl LineIndex { } } } - -/// A small wrapper around a generic io::Write specifically for errors: -/// - Print everything in red to signal it's an error -/// - Keep track of whether anything was printed at all, so that -/// it can be queried whether any errors were encountered at all -pub struct ErrorWriter<W> { - pub writer: W, - pub empty: bool, -} - -impl<W: io::Write> ErrorWriter<W> { - pub fn new(writer: W) -> ErrorWriter<W> { - ErrorWriter { - writer, - empty: true, - } - } - - pub fn write(&mut self, string: &str) -> io::Result<()> { - self.empty = false; - writeln!(self.writer, "{}", string.red()) - } -} |