Skip to content

Commit 0989925

Browse files
committed
fix(reports): use mktemp for parallel-safe HTML report temp file
The fixed filename temp_test_cases.txt caused race conditions when running tests in parallel mode, leading to "No such file or directory" errors when multiple subprocesses accessed the same file.
1 parent 0fffb35 commit 0989925

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ function release::sandbox::create() {
405405
function release::sandbox::setup_git() {
406406
cd "$SANDBOX_DIR"
407407
git init --quiet
408+
git checkout -b main 2>/dev/null || true
408409
git config user.name "Release Sandbox"
409410
git config user.email "sandbox@local"
410411
git add .

src/reports.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ function bashunit::reports::generate_report_html() {
118118
local tests_failed=$(bashunit::state::get_tests_failed)
119119
local time=$(bashunit::clock::total_runtime_in_milliseconds)
120120

121-
# Temporary file to store test cases by file
122-
local temp_file="temp_test_cases.txt"
121+
# Temporary file to store test cases by file (use mktemp for parallel safety)
122+
local temp_file
123+
temp_file=$(mktemp "${TMPDIR:-/tmp}/bashunit-report.XXXXXX")
123124

124125
# Collect test cases by file
125126
: >"$temp_file" # Clear temp file if it exists

tests/unit/release_sandbox_test.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,7 @@ function test_sandbox_setup_git_creates_initial_commit() {
109109
# Should have at least one commit
110110
local commit_count
111111
commit_count=$(git -C "$SANDBOX_DIR" rev-list --count HEAD 2>/dev/null || echo "0")
112-
# In minimal Docker environments, git commit may fail silently
113-
if [ "$commit_count" = "0" ] && [ "${BASH_VERSINFO[0]}" -le 3 ]; then
114-
bashunit::skip "git commit failed in Bash 3.x environment"
115-
else
116-
assert_equals "1" "$commit_count"
117-
fi
112+
assert_equals "1" "$commit_count"
118113

119114
rm -rf "$SANDBOX_DIR"
120115
cd "$original_dir" || return

0 commit comments

Comments
 (0)