Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ quotes around code blocks in error output (#506)
* fix recurring errors on CTRL+C tests with NPM on Windows in selftest suite (#516)
* fixed leaking of local variables from debug trap (#520)
* don't mark FD3 output from `teardown_file` as `<failure>` in junit output (#532)
* fix unbound variable error with Bash pre 4.4 (#550)

#### Documentation

Expand Down
4 changes: 2 additions & 2 deletions libexec/bats-core/bats-exec-file
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -eET

export flags=()
num_jobs=1
export flags=('--dummy-flag')
num_jobs=${BATS_NUMBER_OF_PARALLEL_JOBS:-1}
filter=''
extended_syntax=''
BATS_TRACE_LEVEL="${BATS_TRACE_LEVEL:-0}"
Expand Down
2 changes: 1 addition & 1 deletion libexec/bats-core/bats-exec-suite
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

count_only_flag=''
filter=''
num_jobs=${BATS_NUMBER_OF_PARALLEL_JOBS-1}
num_jobs=${BATS_NUMBER_OF_PARALLEL_JOBS:-1}
bats_no_parallelize_across_files=${BATS_NO_PARALLELIZE_ACROSS_FILES-}
bats_no_parallelize_within_files=
flags=('--dummy-flag') # add a dummy flag to prevent unset varialeb errors on empty array expansion in old bash versions
Expand Down
2 changes: 2 additions & 0 deletions libexec/bats-core/bats-exec-test
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ while [[ "$#" -ne 0 ]]; do
# shellcheck disable=SC2034
BATS_EXTENDED_SYNTAX='-x'
;;
--dummy-flag)
;;
--trace)
(( ++BATS_TRACE_LEVEL )) # avoid returning 0
;;
Expand Down
21 changes: 19 additions & 2 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,24 @@ setup() {
@test 'ensure compatibility with unofficial Bash strict mode' {
local expected='ok 1 unofficial Bash strict mode conditions met'

if [[ -n "$BATS_NUMBER_OF_PARALLEL_JOBS" ]]; then
if [[ -z "$BATS_NO_PARALLELIZE_ACROSS_FILES" ]]; then
type -p parallel &>/dev/null || skip "Don't check file parallelized without GNU parallel"
fi
(type -p flock &>/dev/null || type -p shlock &>/dev/null) || skip "Don't check parallelized without flock/shlock "
fi

# PATH required for windows
# HOME required to avoid error from GNU Parallel
# Run Bats under SHELLOPTS=nounset (recursive `set -u`) to catch
# as many unset variable accesses as possible.
run run_under_clean_bats_env env SHELLOPTS=nounset \
"${BATS_ROOT}/bin/bats" "$FIXTURE_ROOT/unofficial_bash_strict_mode.bats"
run env - \
"PATH=$PATH" \
"HOME=$HOME" \
"BATS_NO_PARALLELIZE_ACROSS_FILES=$BATS_NO_PARALLELIZE_ACROSS_FILES" \
"BATS_NUMBER_OF_PARALLEL_JOBS=$BATS_NUMBER_OF_PARALLEL_JOBS" \
SHELLOPTS=nounset \
"${BATS_ROOT}/bin/bats" "$FIXTURE_ROOT/unofficial_bash_strict_mode.bats"
if [[ "$status" -ne 0 || "${lines[1]}" != "$expected" ]]; then
cat <<END_OF_ERR_MSG

Expand Down Expand Up @@ -633,6 +647,9 @@ END_OF_ERR_MSG
}

@test "Don't hang on CTRL-C (issue #353)" {
if [[ "$BATS_NUMBER_OF_PARALLEL_JOBS" -gt 1 ]]; then
skip "Aborts don't work in parallel mode"
fi
load 'concurrent-coordination'
# shellcheck disable=SC2031,SC2030
export SINGLE_USE_LATCH_DIR="${BATS_TEST_TMPDIR}"
Expand Down
3 changes: 3 additions & 0 deletions test/file_setup_teardown.bats
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ not ok 1 failing test
}

@test "teardown_file should run even after user abort via CTRL-C" {
if [[ "$BATS_NUMBER_OF_PARALLEL_JOBS" -gt 1 ]]; then
skip "Aborts don't work in parallel mode"
fi
# shellcheck disable=SC2031,SC2030
export LOG="$BATS_TEST_TMPDIR/teardown_file_abort.log"
# guarantee that background processes get their own process group -> pid=pgid
Expand Down
7 changes: 0 additions & 7 deletions test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,3 @@ emit_debug_output() {
# shellcheck disable=SC2154
printf '%s\n' 'output:' "$output" >&2
}

run_under_clean_bats_env() {
# we want the variable names to be separate
# shellcheck disable=SC2086
unset ${!BATS_@}
"$@"
}