Skip to content

Commit fd4feaf

Browse files
committed
fix: build issue with bashunit on NixOS
1 parent 7ed61b1 commit fd4feaf

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Fix build issue with bashunit on NixOS
6+
37
## [0.22.2](https://github.com/TypedDevs/bashunit/compare/0.22.1...0.22.2) - 2025-07-26
48

59
- Fix broken core snapshot tests

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ test/list:
6161
@echo $(TEST_SCRIPTS) | tr ' ' '\n'
6262

6363
test: $(TEST_SCRIPTS)
64-
@./bashunit $(TEST_SCRIPTS)
64+
@bash ./bashunit $(TEST_SCRIPTS)
6565

6666
test/watch: $(TEST_SCRIPTS)
67-
@./bashunit $(TEST_SCRIPTS)
68-
@fswatch -m poll_monitor -or $(SRC_SCRIPTS_DIR) $(TEST_SCRIPTS_DIR) .env Makefile | xargs -n1 ./bashunit $(TEST_SCRIPTS)
67+
@bash ./bashunit $(TEST_SCRIPTS)
68+
@fswatch -m poll_monitor -or $(SRC_SCRIPTS_DIR) $(TEST_SCRIPTS_DIR) .env Makefile | xargs -n1 bash ./bashunit $(TEST_SCRIPTS)
6969

7070
docker/alpine:
7171
@docker run --rm -it -v "$(shell pwd)":/project -w /project alpine:latest \

src/env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function env::print_verbose() {
143143
EXIT_CODE_STOP_ON_FAILURE=4
144144
# Use a unique directory per run to avoid conflicts when bashunit is invoked
145145
# recursively or multiple instances are executed in parallel.
146-
TEMP_DIR_PARALLEL_TEST_SUITE="/tmp/bashunit/parallel/${_OS:-Unknown}/$(random_str 8)"
146+
TEMP_DIR_PARALLEL_TEST_SUITE="${TMPDIR:-/tmp}/bashunit/parallel/${_OS:-Unknown}/$(random_str 8)"
147147
TEMP_FILE_PARALLEL_STOP_ON_FAILURE="$TEMP_DIR_PARALLEL_TEST_SUITE/.stop-on-failure"
148148
TERMINAL_WIDTH="$(env::find_terminal_width)"
149149
FAILURES_OUTPUT_PATH=$(mktemp)

src/globals.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,32 @@ function random_str() {
3939

4040
function temp_file() {
4141
local prefix=${1:-bashunit}
42-
mkdir -p /tmp/bashunit/tmp && chmod -R 777 /tmp/bashunit/tmp
42+
local base_dir="${TMPDIR:-/tmp}/bashunit/tmp"
43+
mkdir -p "$base_dir" && chmod -R 777 "$base_dir"
4344
local test_prefix=""
4445
if [[ -n "${BASHUNIT_CURRENT_TEST_ID:-}" ]]; then
4546
test_prefix="${BASHUNIT_CURRENT_TEST_ID}_"
4647
fi
47-
mktemp /tmp/bashunit/tmp/"${test_prefix}${prefix}".XXXXXXX
48+
mktemp "$base_dir/${test_prefix}${prefix}.XXXXXXX"
4849
}
4950

5051
function temp_dir() {
5152
local prefix=${1:-bashunit}
52-
mkdir -p /tmp/bashunit/tmp && chmod -R 777 /tmp/bashunit/tmp
53+
local base_dir="${TMPDIR:-/tmp}/bashunit/tmp"
54+
mkdir -p "$base_dir" && chmod -R 777 "$base_dir"
5355
local test_prefix=""
5456
if [[ -n "${BASHUNIT_CURRENT_TEST_ID:-}" ]]; then
5557
test_prefix="${BASHUNIT_CURRENT_TEST_ID}_"
5658
fi
57-
mktemp -d /tmp/bashunit/tmp/"${test_prefix}${prefix}".XXXXXXX
59+
mktemp -d "$base_dir/${test_prefix}${prefix}.XXXXXXX"
5860
}
5961

6062
function cleanup_temp_files() {
6163
internal_log "cleanup_temp_files"
6264
if [[ -n "${BASHUNIT_CURRENT_TEST_ID:-}" ]]; then
63-
rm -rf /tmp/bashunit/tmp/"${BASHUNIT_CURRENT_TEST_ID}"_*
65+
rm -rf "${TMPDIR:-/tmp}/bashunit/tmp/${BASHUNIT_CURRENT_TEST_ID}"_*
6466
else
65-
rm -rf /tmp/bashunit/tmp/*
67+
rm -rf "${TMPDIR:-/tmp}/bashunit/tmp"/*
6668
fi
6769
}
6870

0 commit comments

Comments
 (0)