From 7cb66fd5791ac95863fa9e13c419af5b25984e90 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 12 Jul 2024 04:10:29 +0200 Subject: [PATCH] tests.makeBinaryWrapper: Prevent rebuilds when Nix files change The source included way more files than it really needed. This commit limits it to exactly those it needs. This also makes sure that no rebuild is necessary when any Nix file changes, in particular useful when we reformat the Nix files. --- pkgs/test/make-binary-wrapper/default.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/test/make-binary-wrapper/default.nix b/pkgs/test/make-binary-wrapper/default.nix index 4c6fffd100a7..0d699900cf6d 100644 --- a/pkgs/test/make-binary-wrapper/default.nix +++ b/pkgs/test/make-binary-wrapper/default.nix @@ -15,16 +15,25 @@ let makeGoldenTest = testname: runCommand "make-binary-wrapper-test-${testname}" env '' mkdir -p tmp/foo # for the chdir test - params=$(<"${./.}/${testname}.cmdline") + source=${lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + (./. + "/${testname}.cmdline") + (./. + "/${testname}.c") + (lib.fileset.maybeMissing (./. + "/${testname}.env")) + ]; + }} + + params=$(<"$source/${testname}.cmdline") eval "makeCWrapper /send/me/flags $params" > wrapper.c - diff wrapper.c "${./.}/${testname}.c" + diff wrapper.c "$source/${testname}.c" - if [ -f "${./.}/${testname}.env" ]; then + if [ -f "$source/${testname}.env" ]; then eval "makeWrapper ${envCheck} wrapped $params" env -i ./wrapped > env.txt sed "s#SUBST_ARGV0#${envCheck}#;s#SUBST_CWD#$PWD#" \ - "${./.}/${testname}.env" > golden-env.txt + "$source/${testname}.env" > golden-env.txt if ! diff env.txt golden-env.txt; then echo "env/argv should be:" cat golden-env.txt