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:
parent
835d944bf9
commit
0c95e842ad
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
test/tmp/*
|
||||
!test/tmp/.keep
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user