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 // in some paths and add regression test #607

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
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
}