aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc-git-receiver/check_shell.sh
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-11 19:52:17 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-10-11 19:52:17 +0200
commit69d5ab4863958fe065ae91440f2d175b55fcf266 (patch)
tree66fc3941377e40a5f61a3829f0419d1d5a9f4ab8 /tests/blogc-git-receiver/check_shell.sh
parentf1acef83fc8c42b628278410de8feec2d2818882 (diff)
downloadblogc-69d5ab4863958fe065ae91440f2d175b55fcf266.tar.gz
blogc-69d5ab4863958fe065ae91440f2d175b55fcf266.tar.bz2
blogc-69d5ab4863958fe065ae91440f2d175b55fcf266.zip
git-receiver: added tests for shell, fixed bug
Diffstat (limited to 'tests/blogc-git-receiver/check_shell.sh')
-rwxr-xr-xtests/blogc-git-receiver/check_shell.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/blogc-git-receiver/check_shell.sh b/tests/blogc-git-receiver/check_shell.sh
new file mode 100755
index 0000000..0367f96
--- /dev/null
+++ b/tests/blogc-git-receiver/check_shell.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+set -xe -o pipefail
+
+export LC_ALL=C
+
+TEMP="$(mktemp -d)"
+[[ -n "${TEMP}" ]]
+
+trap_func() {
+ [[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt"
+ rm -rf "${TEMP}"
+}
+
+trap trap_func EXIT
+
+SELF="${PWD}/blogc-git-receiver"
+
+call_bgr() {
+ [[ -n "${VALGRIND}" ]] && export __VALGRIND_ENABLED=1
+ SHELL="${SELF}" HOME="${TEMP}" ${TESTS_ENVIRONMENT} "${SELF}" "$@"
+}
+
+call_bgr -c "bola 'lol.git'" 2>&1 | tee "${TEMP}/output.txt" || true
+grep "error: invalid git-shell command: bola 'lol\.git'" "${TEMP}/output.txt" &> /dev/null
+
+echo 0000 | call_bgr -c "git-receive-pack 'lol.git'" 2>&1 > "${TEMP}/output.txt"
+if [[ -n "${VALGRIND}" ]]; then
+ grep "git-shell -c \"git-receive-pack '.*repos/lol.git'\"" "${TEMP}/output.txt" &> /dev/null
+else
+ grep "agent=" "${TEMP}/output.txt" &> /dev/null
+fi
+[[ -d "${TEMP}/repos/lol.git" ]]
+[[ -h "${TEMP}/repos/lol.git/hooks/pre-receive" ]]
+[[ "$(readlink "${TEMP}/repos/lol.git/hooks/pre-receive")" == "${SELF}" ]]
+[[ -h "${TEMP}/repos/lol.git/hooks/post-receive" ]]
+[[ "$(readlink "${TEMP}/repos/lol.git/hooks/post-receive")" == "${SELF}" ]]
+
+cat > "${TEMP}/tmp.txt" <<EOF
+blob
+mark :1
+data 4
+bar
+
+reset refs/heads/master
+commit refs/heads/master
+mark :2
+author Rafael G. Martins <rafael@rafaelmartins.eng.br> 1476033730 +0200
+committer Rafael G. Martins <rafael@rafaelmartins.eng.br> 1476033888 +0200
+data 11
+testing...
+M 100644 :1 foo
+
+EOF
+cd "${TEMP}/repos/lol.git"
+git fast-import < "${TEMP}/tmp.txt" &> /dev/null
+cd - > /dev/null
+
+echo 0000 | call_bgr -c "git-upload-pack 'lol.git'" 2>&1 > "${TEMP}/output.txt"
+if [[ -n "${VALGRIND}" ]]; then
+ grep "git-shell -c \"git-upload-pack '.*repos/lol.git'\"" "${TEMP}/output.txt" &> /dev/null
+else
+ grep "agent=" "${TEMP}/output.txt" &> /dev/null
+fi
+
+echo 0000 | call_bgr -c "git-upload-archive 'lol.git'" 2>&1 > "${TEMP}/output.txt" || true
+if [[ -n "${VALGRIND}" ]]; then
+ grep "git-shell -c \"git-upload-archive '.*repos/lol.git'\"" "${TEMP}/output.txt" &> /dev/null
+else
+ grep "ACK" "${TEMP}/output.txt" &> /dev/null
+fi
+
+rm "${TEMP}/output.txt"