File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,12 +120,15 @@ function bashunit::reports::generate_junit_xml() {
120120
121121function bashunit::reports::__gha_encode() {
122122 local text=" $1 "
123- # Strip ANSI escape sequences, then percent-encode reserved chars
124- # (see GitHub Actions workflow-commands docs: %25, %0A, %0D)
125- echo " $text " \
126- | sed -e ' s/\x1b\[[0-9;]*[a-zA-Z]//g' \
127- | awk ' BEGIN{ORS=""} {gsub(/%/,"%25"); gsub(/\r/,"%0D"); print; if (NR>0) print "%0A"}' \
128- | sed -e ' s/%0A$//'
123+ # Strip ANSI escape sequences first (one sed call)
124+ text=$( printf ' %s' " $text " | sed -e ' s/\x1b\[[0-9;]*[a-zA-Z]//g' )
125+ # Percent-encode reserved chars per GHA workflow-commands spec.
126+ # Bash 3.0+ parameter expansion avoids extra awk/sed calls.
127+ # Order matters: encode '%' first so the sequences we inject stay literal.
128+ text=" ${text//%/% 25} "
129+ text=" ${text// $' \r ' /% 0D} "
130+ text=" ${text// $' \n ' /% 0A} "
131+ printf ' %s' " $text "
129132}
130133
131134function bashunit::reports::generate_gha_log() {
Original file line number Diff line number Diff line change @@ -7,21 +7,25 @@ function set_up_before_script() {
77
88function test_bashunit_when_log_gha_option() {
99 local test_file=./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
10+ local log_file
11+ log_file=$( mktemp " ${TMPDIR:-/ tmp} /bashunit-gha-opt.XXXXXX" )
1012
11- ./bashunit --no-parallel --env " $TEST_ENV_FILE " --log-gha custom.log " $test_file " > /dev/null
13+ # Inner suite has a failing test, so bashunit exits nonzero; tolerate it
14+ # so the acceptance test keeps running under --strict (set -e).
15+ ./bashunit --no-parallel --env " $TEST_ENV_FILE " --log-gha " $log_file " " $test_file " > /dev/null || true
1216
13- assert_file_exists custom.log
14- assert_contains " ::error file=$test_file " " $( cat custom.log ) "
15- assert_contains " title=Failure" " $( cat custom.log ) "
16- rm custom.log
17+ assert_file_exists " $log_file "
18+ assert_contains " ::error file=$test_file " " $( cat " $log_file " ) "
19+ assert_contains " title=Failure" " $( cat " $log_file " ) "
20+ rm -f " $log_file "
1721}
1822
1923function test_bashunit_when_log_gha_env() {
2024 local test_file=./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
2125
22- ./bashunit --no-parallel --env " $TEST_ENV_FILE_BASHUNIT_LOG_GHA " " $test_file " > /dev/null
26+ ./bashunit --no-parallel --env " $TEST_ENV_FILE_BASHUNIT_LOG_GHA " " $test_file " > /dev/null || true
2327
2428 assert_file_exists log-gha.txt
2529 assert_contains " ::error" " $( cat log-gha.txt) "
26- rm log-gha.txt
30+ rm -f log-gha.txt
2731}
You can’t perform that action at this time.
0 commit comments