Skip to content

Commit 3b026de

Browse files
committed
test(coverage): skip subshell tests under parallel mode and on Git Bash
Enabling the DEBUG trap inside a parallel test worker process makes the worker fire the trap on every internal coordination command, which combines with /tmp file-I/O contention to deadlock CI runners (15-minute timeouts on Ubuntu/Alpine parallel jobs and on Windows Git Bash). The contracts these tests pin are deterministic in single-process mode, so the parallel run is not a useful execution context. Adds a guard that calls bashunit::skip when BASHUNIT_PARALLEL_RUN=true or when running on CYGWIN/MINGW/MSYS, and applies it to all five subshell tests.
1 parent 46dbad5 commit 3b026de

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/unit/coverage_subshell_test.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ _ORIG_COVERAGE=""
1414
_ORIG_COVERAGE_PATHS=""
1515
_ORIG_COVERAGE_EXCLUDE=""
1616

17+
# Whole-suite skip: enabling the DEBUG trap inside a parallel test
18+
# worker process makes the worker fire the trap on every internal
19+
# coordination command, which combines with file-I/O contention on
20+
# /tmp to deadlock CI runners. The contracts tested here are
21+
# deterministic in single-process mode, so the parallel run is not
22+
# a useful execution context.
23+
function _skip_when_parallel_or_windows() {
24+
if [ "${BASHUNIT_PARALLEL_RUN:-false}" = "true" ]; then
25+
bashunit::skip "subshell tracking tests require single-process execution"
26+
return 0
27+
fi
28+
case "$(uname -s 2>/dev/null)" in
29+
CYGWIN* | MINGW* | MSYS*)
30+
bashunit::skip "DEBUG trap + set -T behavior is unstable on Git Bash"
31+
return 0
32+
;;
33+
esac
34+
return 1
35+
}
36+
1737
function set_up() {
1838
_ORIG_COVERAGE_DATA_FILE="$_BASHUNIT_COVERAGE_DATA_FILE"
1939
_ORIG_COVERAGE_TRACKED_FILES="$_BASHUNIT_COVERAGE_TRACKED_FILES"
@@ -85,6 +105,7 @@ function _run_fixture_under_coverage() {
85105
}
86106

87107
function test_coverage_records_lines_inside_command_substitution() {
108+
_skip_when_parallel_or_windows && return 0
88109
local fixture
89110
fixture=$(mktemp)
90111
cat >"$fixture" <<'EOF'
@@ -104,6 +125,7 @@ EOF
104125
}
105126

106127
function test_coverage_records_explicit_subshell_block() {
128+
_skip_when_parallel_or_windows && return 0
107129
local fixture
108130
fixture=$(mktemp)
109131
cat >"$fixture" <<'EOF'
@@ -125,6 +147,7 @@ EOF
125147
}
126148

127149
function test_coverage_records_pipeline_lhs() {
150+
_skip_when_parallel_or_windows && return 0
128151
local fixture
129152
fixture=$(mktemp)
130153
cat >"$fixture" <<'EOF'
@@ -142,6 +165,7 @@ EOF
142165
}
143166

144167
function test_coverage_records_process_substitution_consumer() {
168+
_skip_when_parallel_or_windows && return 0
145169
local fixture
146170
fixture=$(mktemp)
147171
cat >"$fixture" <<'EOF'
@@ -162,6 +186,7 @@ EOF
162186
}
163187

164188
function test_coverage_records_lines_inside_function_called_from_subshell() {
189+
_skip_when_parallel_or_windows && return 0
165190
local fixture
166191
fixture=$(mktemp)
167192
cat >"$fixture" <<'EOF'

0 commit comments

Comments
 (0)