File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,17 +40,29 @@ function random_str() {
4040function temp_file() {
4141 local prefix=${1:- bashunit}
4242 mkdir -p /tmp/bashunit/tmp && chmod -R 777 /tmp/bashunit/tmp
43- mktemp /tmp/bashunit/tmp/" $prefix " .XXXXXXX
43+ local test_prefix=" "
44+ if [[ -n " ${BASHUNIT_CURRENT_TEST_ID:- } " ]]; then
45+ test_prefix=" ${BASHUNIT_CURRENT_TEST_ID} _"
46+ fi
47+ mktemp /tmp/bashunit/tmp/" ${test_prefix}${prefix} " .XXXXXXX
4448}
4549
4650function temp_dir() {
4751 local prefix=${1:- bashunit}
4852 mkdir -p /tmp/bashunit/tmp && chmod -R 777 /tmp/bashunit/tmp
49- mktemp -d /tmp/bashunit/tmp/" $prefix " .XXXXXXX
53+ local test_prefix=" "
54+ if [[ -n " ${BASHUNIT_CURRENT_TEST_ID:- } " ]]; then
55+ test_prefix=" ${BASHUNIT_CURRENT_TEST_ID} _"
56+ fi
57+ mktemp -d /tmp/bashunit/tmp/" ${test_prefix}${prefix} " .XXXXXXX
5058}
5159
5260function cleanup_temp_files() {
53- rm -rf /tmp/bashunit/tmp/*
61+ if [[ -n " ${BASHUNIT_CURRENT_TEST_ID:- } " ]]; then
62+ rm -rf /tmp/bashunit/tmp/" ${BASHUNIT_CURRENT_TEST_ID} " _*
63+ else
64+ rm -rf /tmp/bashunit/tmp/*
65+ fi
5466}
5567
5668# shellcheck disable=SC2145
You can’t perform that action at this time.
0 commit comments