Skip to content

Commit

Permalink
Merge pull request #607 from martin-schulze-vireso/fix/issue_605_doub…
Browse files Browse the repository at this point in the history
…le_slashes_in_paths

Fix // in some paths and add regression test
  • Loading branch information
martin-schulze-vireso committed Jun 5, 2022
2 parents eb6b74f + 5e328bf commit 4ac6530
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog][kac] and this project adheres to
* allow `--gather-test-outputs-in <directory>` to work with existing, empty
directories (#603)
* also add `--clean-and-gather-test-outpust-in <directory>` for improved UX
* double slashes in paths derived from TMPDIR on MacOS (#607)

#### Documentation

Expand Down
1 change: 1 addition & 0 deletions libexec/bats-core/bats
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export BATS_TEST_FILTER=
export PATH="$BATS_LIBEXEC:$PATH"
export BATS_ROOT_PID=$$
export BATS_TMPDIR="${TMPDIR:-/tmp}"
BATS_TMPDIR=${BATS_TMPDIR%/} # chop off trailing / to avoid duplication
export BATS_RUN_TMPDIR=
export BATS_GUARANTEED_MINIMUM_VERSION=0.0.0

Expand Down
2 changes: 1 addition & 1 deletion libexec/bats-core/bats-exec-test
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ elif [[ ! -f "$BATS_TEST_FILENAME" ]]; then
fi

bats_create_test_tmpdirs() {
local tests_tmpdir="${BATS_RUN_TMPDIR}/test/"
local tests_tmpdir="${BATS_RUN_TMPDIR}/test"
if ! mkdir -p "$tests_tmpdir"; then
printf 'Failed to create: %s\n' "$tests_tmpdir" >&2
exit 1
Expand Down
4 changes: 4 additions & 0 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1228,4 +1228,8 @@ END_OF_ERR_MSG
TEARDOWN_RETURN_CODE=1 TEST_RETURN_CODE=1 STATUS=0 run -1 bats "$FIXTURE_ROOT/teardown_suite_override_status/"
TEARDOWN_RETURN_CODE=0 TEST_RETURN_CODE=0 STATUS=1 run -0 bats "$FIXTURE_ROOT/teardown_suite_override_status/"
TEARDOWN_RETURN_CODE=1 TEST_RETURN_CODE=0 STATUS=1 run -1 bats "$FIXTURE_ROOT/teardown_suite_override_status/"
}

@test "BATS_* variables don't contain double slashes" {
TMPDIR=/tmp/ bats "$FIXTURE_ROOT/BATS_variables_dont_contain_double_slashes.bats"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@test "BATS_* variables don't contain double slashes" {
for var_name in ${!BATS_@}; do
local var_value="${!var_name}"
if [[ "$var_value" == *'//'* ]]; then

echo "$var_name contains // ${#var_value}: ${var_value}" && false
fi
done
}

0 comments on commit 4ac6530

Please sign in to comment.