From 994d854a4a90df8d8f661b19d05eb1cb6a951419 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sun, 5 Oct 2025 14:33:38 -0500 Subject: [PATCH] tests/grep: add tests Signed-off-by: Austin Horstman --- .../programs/grep/basic-configuration.nix | 13 +++++++++++++ tests/modules/programs/grep/default.nix | 4 ++++ tests/modules/programs/grep/with-colors.nix | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tests/modules/programs/grep/basic-configuration.nix create mode 100644 tests/modules/programs/grep/default.nix create mode 100644 tests/modules/programs/grep/with-colors.nix diff --git a/tests/modules/programs/grep/basic-configuration.nix b/tests/modules/programs/grep/basic-configuration.nix new file mode 100644 index 000000000..845b02cca --- /dev/null +++ b/tests/modules/programs/grep/basic-configuration.nix @@ -0,0 +1,13 @@ +{ + config = { + programs.grep = { + enable = true; + }; + + nmt.script = '' + # Verify no GREP_COLORS environment variable is set when colors is empty + hmEnvFile=home-path/etc/profile.d/hm-session-vars.sh + assertFileNotRegex $hmEnvFile 'GCC_COLORS' + ''; + }; +} diff --git a/tests/modules/programs/grep/default.nix b/tests/modules/programs/grep/default.nix new file mode 100644 index 000000000..a68789756 --- /dev/null +++ b/tests/modules/programs/grep/default.nix @@ -0,0 +1,4 @@ +{ + grep-basic-configuration = ./basic-configuration.nix; + grep-with-colors = ./with-colors.nix; +} diff --git a/tests/modules/programs/grep/with-colors.nix b/tests/modules/programs/grep/with-colors.nix new file mode 100644 index 000000000..a76c58e1b --- /dev/null +++ b/tests/modules/programs/grep/with-colors.nix @@ -0,0 +1,17 @@ +{ + config = { + programs.grep = { + enable = true; + colors = { + error = "01;31"; + match = "01;32"; + }; + }; + + nmt.script = '' + # Check that grep colors are set in session variables + assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ + 'export GREP_COLORS="error=01;31:match=01;32"' + ''; + }; +}