aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc-git-receiver
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-11 22:13:05 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-11 22:13:05 +0200
commit0e38d3acd98b6cf472f60cea735af8a100a3f5b0 (patch)
tree40f818e69523aa20fccc1b7333c42a0638f3dcb2 /tests/blogc-git-receiver
parent69d5ab4863958fe065ae91440f2d175b55fcf266 (diff)
downloadblogc-0e38d3acd98b6cf472f60cea735af8a100a3f5b0.tar.gz
blogc-0e38d3acd98b6cf472f60cea735af8a100a3f5b0.tar.bz2
blogc-0e38d3acd98b6cf472f60cea735af8a100a3f5b0.zip
tests: git-receiver: avoid removing directories for safety
Diffstat (limited to 'tests/blogc-git-receiver')
-rwxr-xr-xtests/blogc-git-receiver/check_post_receive.sh17
-rwxr-xr-xtests/blogc-git-receiver/check_pre_receive.sh16
-rwxr-xr-xtests/blogc-git-receiver/check_shell.sh2
3 files changed, 15 insertions, 20 deletions
diff --git a/tests/blogc-git-receiver/check_post_receive.sh b/tests/blogc-git-receiver/check_post_receive.sh
index 954787b..b1c8246 100755
--- a/tests/blogc-git-receiver/check_post_receive.sh
+++ b/tests/blogc-git-receiver/check_post_receive.sh
@@ -9,7 +9,7 @@ TEMP="$(mktemp -d)"
trap_func() {
[[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt"
- rm -rf "${TEMP}"
+ [[ -n "${TEMP}" ]] && rm -rf "${TEMP}"
}
trap trap_func EXIT
@@ -49,40 +49,37 @@ HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/out
grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null
git config --local --unset remote.mirror.pushurl
-rm -rf "${TEMP}/repos/bar.git"
-git init --bare "${TEMP}/repos/bar.git" &> /dev/null
-git config --local remote.mirror.url "${TEMP}/repos/bar.git"
+git init --bare "${TEMP}/repos/bar2.git" &> /dev/null
+git config --local remote.mirror.url "${TEMP}/repos/bar2.git"
HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt"
grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null
git config --local --unset remote.mirror.url
-rm -rf "${TEMP}/repos/bar.git"
cat > "${TEMP}/blogc-git-receiver.ini" <<EOF
[repo:boo.git]
mirror = 123
[repo:foo.git]
-mirror = ${TEMP}/repos/bar.git
+mirror = ${TEMP}/repos/bar3.git
[repo:bar.git]
mirror = lol
EOF
-git init --bare "${TEMP}/repos/bar.git" &> /dev/null
+git init --bare "${TEMP}/repos/bar3.git" &> /dev/null
HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt"
grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null
-rm -rf "${TEMP}/repos/bar.git"
cat > "${TEMP}/blogc-git-receiver.ini" <<EOF
asd[repo:boo.git]
mirror = 123
[repo:foo.git]
-mirror = ${TEMP}/repos/bar.git
+mirror = ${TEMP}/repos/bar4.git
[repo:bar.git]
mirror = lol
EOF
-git init --bare "${TEMP}/repos/bar.git" &> /dev/null
+git init --bare "${TEMP}/repos/bar4.git" &> /dev/null
HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/post-receive 2>&1 | tee "${TEMP}/output.txt"
grep "warning: failed to parse configuration file " "${TEMP}/output.txt" &> /dev/null
diff --git a/tests/blogc-git-receiver/check_pre_receive.sh b/tests/blogc-git-receiver/check_pre_receive.sh
index dc2066f..7ef7f0e 100755
--- a/tests/blogc-git-receiver/check_pre_receive.sh
+++ b/tests/blogc-git-receiver/check_pre_receive.sh
@@ -9,7 +9,7 @@ TEMP="$(mktemp -d)"
trap_func() {
[[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt"
- rm -rf "${TEMP}"
+ [[ -n "${TEMP}" ]] && rm -rf "${TEMP}"
}
trap trap_func EXIT
@@ -62,9 +62,8 @@ SHELL="${SELF}" HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEM
grep "warning: no makefile found. skipping ..." "${TEMP}/output.txt" &> /dev/null
cd "${TEMP}"
-rm -rf "${TEMP}/repos/foo.git"
-git init --bare "${TEMP}/repos/foo.git" &> /dev/null
-ln -s "${SELF}" "${TEMP}/repos/foo.git/hooks/pre-receive"
+git init --bare "${TEMP}/repos/foo2.git" &> /dev/null
+ln -s "${SELF}" "${TEMP}/repos/foo2.git/hooks/pre-receive"
cat > "${TEMP}/tmp.txt" <<EOF
blob
@@ -85,7 +84,7 @@ M 100644 :1 Makefile
EOF
-cd "${TEMP}/repos/foo.git"
+cd "${TEMP}/repos/foo2.git"
git fast-import < "${TEMP}/tmp.txt" &> /dev/null
cat > "${TEMP}/payload.txt" <<EOF
@@ -104,9 +103,8 @@ DEST="$(readlink htdocs)"
[[ -e "${DEST}" ]]
cd "${TEMP}"
-rm -rf "${TEMP}/repos/foo.git"
-git init --bare "${TEMP}/repos/foo.git" &> /dev/null
-ln -s "${SELF}" "${TEMP}/repos/foo.git/hooks/pre-receive"
+git init --bare "${TEMP}/repos/foo3.git" &> /dev/null
+ln -s "${SELF}" "${TEMP}/repos/foo3.git/hooks/pre-receive"
cat > "${TEMP}/tmp.txt" <<EOF
blob
@@ -127,7 +125,7 @@ M 100644 :1 Makefile
EOF
-cd "${TEMP}/repos/foo.git"
+cd "${TEMP}/repos/foo3.git"
ln -s "${DEST}" htdocs
git fast-import < "${TEMP}/tmp.txt" &> /dev/null
diff --git a/tests/blogc-git-receiver/check_shell.sh b/tests/blogc-git-receiver/check_shell.sh
index 0367f96..64f105e 100755
--- a/tests/blogc-git-receiver/check_shell.sh
+++ b/tests/blogc-git-receiver/check_shell.sh
@@ -9,7 +9,7 @@ TEMP="$(mktemp -d)"
trap_func() {
[[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt"
- rm -rf "${TEMP}"
+ [[ -n "${TEMP}" ]] && rm -rf "${TEMP}"
}
trap trap_func EXIT