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 @@ The format is based on [Keep a Changelog][kac] and this project adheres to
* fix `run` with options overwriting the value of `i` (#726, #727)
* fix `${BATS_TEST_NAMES[@]}` containing only `--tags` instead of test name since Bats v1.8.0 (#705)
* fix `run --keep-empty-lines` counting trailing `\n` as (empty) new line (#711)
* fix short flag unpacker creating bogus command lines with valued flags (#732)

#### Documentation

Expand Down
8 changes: 8 additions & 0 deletions libexec/bats-core/bats
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ fi

arguments=()

# list of single char options that don't expect a value
single_char_flags="hvcprtTx"

# Unpack single-character options bundled together, e.g. -cr, -pr.
for arg in "$@"; do
if [[ "$arg" =~ ^-[^-]. ]]; then
Expand All @@ -141,6 +144,11 @@ for arg in "$@"; do
if [[ -z "$option" ]]; then
break
fi
if [[ "$single_char_flags" != *$option* && -n "${arg:index}" ]]; then
printf "Error: -%s is not allowed within pack of flags.\n" "$option"
printf " Please put it last (e.g. \`-rF junit\` instead of \`-Fr junit\`), or on its own (\`-r -F junit\`)!\n"
exit 1
fi
arguments+=("-$option")
done
else
Expand Down
8 changes: 8 additions & 0 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1563,3 +1563,11 @@ enforce_own_process_group() {

[[ "${output}" = *"ERROR: command \`$REPORT_FORMATTER\` failed with status 11"* ]] || false
}

@test "Short opt unpacker rejects valued options" {
bats_require_minimum_version 1.5.0
reentrant_run ! bats "$FIXTURE_ROOT/passing.bats" -Fr tap
[[ "${output}" == *"Error: -F is not allowed within pack of flags."* ]] || false

reentrant_run -0 bats "$FIXTURE_ROOT/passing.bats" -rF tap
}
7 changes: 0 additions & 7 deletions test/parallel.bats
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ check_parallel_tests() { # <expected maximum parallelity>
DISABLE_IN_TEST_FUNCTION=1 reentrant_run ! bats --jobs 2 "$FIXTURE_ROOT/must_not_parallelize_within_file.bats"
}

@test "Short form typo does not run endlessly" {
unset BATS_NO_PARALLELIZE_ACROSS_FILES
run bats -j2 "$FIXTURE_ROOT/../bats/passing.bats"
(( SECONDS < 5 ))
[ "${lines[1]}" = 'Invalid number of jobs: -2' ]
}

@test "Negative jobs number does not run endlessly" {
unset BATS_NO_PARALLELIZE_ACROSS_FILES
run bats -j -3 "$FIXTURE_ROOT/../bats/passing.bats"
Expand Down