From 9b6f77200f8a88c8b5e5da47e90b73f86aab27b9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 22 May 2024 13:34:01 -0400 Subject: [PATCH] environment: Rework test to assert against full $PATH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s deterministic after all, so test against the full thing for greater flexibility in testing and confidence in lack of unexpected changes to previously-untested parts of the default $PATH. Do this in a subshell to avoid polluting the test script’s environment. --- tests/environment-path.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/environment-path.nix b/tests/environment-path.nix index 7d2f46dd..5ddaf9c9 100644 --- a/tests/environment-path.nix +++ b/tests/environment-path.nix @@ -4,10 +4,18 @@ with lib; { test = '' - echo checking /run/current-system/sw/bin in environment >&2 - grep 'export PATH=.*:/run/current-system/sw/bin' ${config.system.build.setEnvironment} + echo 'checking PATH' >&2 + env_path=$(bash -c 'source ${config.system.build.setEnvironment}; echo $PATH') - echo checking /bin and /sbin in environment >&2 - grep 'export PATH=.*:/usr/bin:/usr/sbin:/bin:/sbin' ${config.system.build.setEnvironment} + test "$env_path" = "${builtins.concatStringsSep ":" [ + "/homeless-shelter/.nix-profile/bin" + "/run/current-system/sw/bin" + "/nix/var/nix/profiles/default/bin" + "/usr/local/bin" + "/usr/bin" + "/usr/sbin" + "/bin" + "/sbin" + ]}" ''; }