Skip to content

Commit f46a3b9

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 f46a3b9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

0 commit comments

Comments
 (0)