1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-22 04:45:11 +00:00

Use /tmp directory for temp file generated with mktemp.

Moving to `mktemp` with files in /tmp makes it possible to remove the
local test/tmp directory.
This commit is contained in:
William Melody 2016-01-24 22:31:42 -08:00
parent 835d944bf9
commit 0c95e842ad
3 changed files with 8 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
test/tmp/*
!test/tmp/.keep

View File

@ -4,10 +4,15 @@ setup() {
# The location of the `hosts` script being tested.
export _HOSTS="${BATS_TEST_DIRNAME}/../hosts"
export HOSTS_PATH="${BATS_TEST_DIRNAME}/tmp/hosts"
cp "${BATS_TEST_DIRNAME}/fixtures/hosts" "${BATS_TEST_DIRNAME}/tmp/hosts"
export HOSTS_PATH="$(mktemp /tmp/hosts_test.XXXXXX)" || exit 1
cat "${BATS_TEST_DIRNAME}/fixtures/hosts" > "${HOSTS_PATH}"
}
teardown() {
rm "${BATS_TEST_DIRNAME}/tmp/hosts"
if [[ -n "${HOSTS_PATH}" ]] &&
[[ -e "${HOSTS_PATH}" ]] &&
[[ "${HOSTS_PATH}" =~ ^/tmp ]]
then
rm "${HOSTS_PATH}"
fi
}

View File