From 6bc5747951d3907c918400463f4eae4fe962df27 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Mon, 18 Aug 2025 13:28:00 +0200 Subject: [PATCH] run-tests: fix `tmpDir` being deleted before it's used In `buildTests`, `nixInstantiate` is called in a subshell. When `tmpDir` is unset before the call, the tmpdir is created in the subshell and gets deleted before subshell exit (via `trap`). But subsequent code accesses the tmpdir, which has now been deleted, leading to an error. This bug has been undetected for a long time because bash 5.2 has a bug [1] where `trap` is not always executed, causing the tmpdir to never be deleted. Bash 5.3 (introduced in NixOS 25.05) now works correctly and exposes the bug. Fix it by creating the tmpdir before the subshell call. [1] https://mail.gnu.org/archive/html/help-bash/2024-07/msg00007.html --- test/run-tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/run-tests.sh b/test/run-tests.sh index 48abf8e..2c4da76 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -190,6 +190,7 @@ buildTestAttr() { buildTests() { local -n tests=$1 shift + makeTmpDir # TODO-EXTERNAL: # Simplify and switch to pure build when `nix build` can instantiate flake function outputs # shellcheck disable=SC2207