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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user