Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix endless loop on CTRL-C with bash 5.2 #656

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
bash-version:
strategy:
matrix:
version: ['3.2', '4.0', '4.1', '4.2', '4.3', '4.4', '4', '5.0', '5.1', '5', 'latest']
version: ['3.2', '4.0', '4.1', '4.2', '4.3', '4.4', '4', '5.0', '5.1', '5', 'rc']
env_vars:
- ''
# also test running (recursively!) in parallel
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog][kac] and this project adheres to
### Fixed

* `shfmt` all files and enforce via CI (#651)
* avoid kernel warning flood/hang with CTRL+C on Bash 5.2 RC (#656)

## [1.8.0] - 2022-09-15

Expand Down
5 changes: 2 additions & 3 deletions lib/bats-core/tracing.bash
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ bats_interrupt_trap() {
BATS_INTERRUPTED=true
BATS_ERROR_STATUS=130
# debug trap fires before interrupt trap but gets wrong linenumber (line 1)
# -> use last stack trace
exit $BATS_ERROR_STATUS
# -> use last stack trace instead of BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=true
}

# this is used inside run()
Expand All @@ -392,5 +391,5 @@ bats_interrupt_trap_in_run() {
BATS_INTERRUPTED=true
BATS_ERROR_STATUS=130
BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=true
exit $BATS_ERROR_STATUS
exit 130
}
12 changes: 6 additions & 6 deletions libexec/bats-core/bats-format-junit
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ print_test_case() {
}

xml_escape() {
output=${1//&/&}
output=${output//</&lt;}
output=${output//>/&gt;}
output=${output//'"'/&quot;}
output=${output//\'/&#39;}
output=${1//&/\&amp;}
output=${output//</\&lt;}
output=${output//>/\&gt;}
output=${output//'"'/\&quot;}
output=${output//\'/\&#39;}
local CONTROL_CHAR=$'\033'
output="${output//$CONTROL_CHAR/&#27;}"
output=${output//$CONTROL_CHAR/\&#27;}
printf "%s" "$output"
}

Expand Down
2 changes: 2 additions & 0 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,10 @@ END_OF_ERR_MSG

[ "${lines[1]}" == "not ok 1 test" ]
# due to scheduling the exact line will vary but we should exit with 130
[[ "${lines[2]}" == "# (in test file "*")" ]] || false
[[ "${lines[3]}" == *"failed with status 130" ]] || false
[ "${lines[4]}" == "# Received SIGINT, aborting ..." ]
[ ${#lines[@]} -eq 5 ]
}

@test "CTRL-C aborts and fails the current run" {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/bats/hang_in_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ setup() {
@test "test" {
single-use-latch::signal hang_in_test
sleep 10
echo "after sleep" # this should not be printed
}