diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Prefer POSIX forms throughout the test scripts
-rw-r--r--tests/Makefile3
-rwxr-xr-xtests/filters/dump.sh6
-rwxr-xr-xtests/setup.sh8
-rwxr-xr-xtests/t0001-git-version.sh3
-rwxr-xr-xtests/t0002-html-validity.sh3
-rwxr-xr-xtests/t0201-filters.sh3
-rwxr-xr-xtests/t0204-limits.sh7
-rwxr-xr-xtests/t0302-home-access.sh2
-rwxr-xr-xtests/valgrind/bin/cgit7
9 files changed, 28 insertions, 14 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 1047de5..7a8beb1 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -4,6 +4,9 @@
# to pass extra options along. The top-level Makefile reaches this through its
# test target, once cgit and the Git tree it links against have been built.
+.DEFAULT_GOAL := all
+.SUFFIXES:
+
# SHELL_PATH comes from Git's platform detection, and cgit.conf may override it,
# so both are read before anything below uses it.
include ../vendor/git/config.mak.uname
diff --git a/tests/filters/dump.sh b/tests/filters/dump.sh
index da6f7a1..a4c1571 100755
--- a/tests/filters/dump.sh
+++ b/tests/filters/dump.sh
@@ -1,4 +1,8 @@
#!/bin/sh
-[ "$#" -gt 0 ] && printf "%s " "$*"
+# Test fixture for the cgit exec filter API, exercised by t0201-filters.sh.
+# It echoes the arguments it was invoked with and upper-cases the body, which
+# lets the test confirm that both flow through the exec: filter path.
+
+test "$#" -gt 0 && printf "%s " "$*"
tr '[:lower:]' '[:upper:]'
diff --git a/tests/setup.sh b/tests/setup.sh
index 93a663a..aac498c 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -56,7 +56,8 @@ FILTER_DIRECTORY=$(cd ../filters && pwd)
# Lua filters only work when cgit was compiled with Lua, so the tests that use
# them have to ask the binary rather than assume.
-if cgit --version | grep -F -q "[+] Lua scripting"; then
+if cgit --version | grep -F -q "[+] Lua scripting"
+then
export CGIT_HAS_LUA=1
else
export CGIT_HAS_LUA=0
@@ -78,7 +79,7 @@ mkrepo() {
echo $n >file-$n
git add file-$n
git commit -m "commit $n"
- n=$(expr $n + 1)
+ n=$((n + 1))
done
case "$variant" in
testplus)
@@ -146,7 +147,8 @@ repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh
repo.readme=master:a+b
EOF
- if [ $CGIT_HAS_LUA -eq 1 ]; then
+ if test "$CGIT_HAS_LUA" -eq 1
+ then
cat >>cgitrc <<EOF
repo.url=filter-lua
repo.path=$PWD/repos/filter/.git
diff --git a/tests/t0001-git-version.sh b/tests/t0001-git-version.sh
index 2117764..8436812 100755
--- a/tests/t0001-git-version.sh
+++ b/tests/t0001-git-version.sh
@@ -7,7 +7,8 @@
# it claims. Set CGIT_TEST_NO_GIT_VERSION to YesPlease when Git comes from
# elsewhere and the comparison has nothing to say.
-if [ "${CGIT_TEST_NO_GIT_VERSION}" = "YesPlease" ]; then
+if test "$CGIT_TEST_NO_GIT_VERSION" = "YesPlease"
+then
exit 0
fi
diff --git a/tests/t0002-html-validity.sh b/tests/t0002-html-validity.sh
index 842437c..d5103d2 100755
--- a/tests/t0002-html-validity.sh
+++ b/tests/t0002-html-validity.sh
@@ -32,8 +32,7 @@ test_url()
fi
}
-tidy=$(which tidy 2>/dev/null)
-test -n "$tidy" || {
+tidy=$(command -v tidy) || {
skip_all='Skipping html validation tests: tidy not found'
test_done
exit
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 88533f4..971ec36 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -10,7 +10,8 @@ test_description='Check filtered content'
. ./setup.sh
prefixes="exec"
-if [ $CGIT_HAS_LUA -eq 1 ]; then
+if test "$CGIT_HAS_LUA" -eq 1
+then
prefixes="$prefixes lua"
fi
diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh
index f09c290..d35dc69 100755
--- a/tests/t0204-limits.sh
+++ b/tests/t0204-limits.sh
@@ -12,7 +12,8 @@
test_description='Check the ref listing and diff size limits'
. ./setup.sh
-if [ $CGIT_HAS_LUA -eq 1 ]; then
+if test "$CGIT_HAS_LUA" -eq 1
+then
test_set_prereq LUA
fi
@@ -24,11 +25,11 @@ test_expect_success 'set up limit fixtures' '
mkrepo repos/limits 1 &&
(
cd repos/limits &&
- seq 1 60 >big.c &&
+ test_seq 1 60 >big.c &&
printf "int x;\n" >small.c &&
git add -A &&
git commit -m sources &&
- seq 301 360 >big.c &&
+ test_seq 301 360 >big.c &&
printf "int y;\n" >small.c &&
git commit -am change &&
for i in 1 2 3; do git branch branch-$i || exit 1; done &&
diff --git a/tests/t0302-home-access.sh b/tests/t0302-home-access.sh
index 7078596..89aa00f 100755
--- a/tests/t0302-home-access.sh
+++ b/tests/t0302-home-access.sh
@@ -12,7 +12,7 @@ test_description='Ensure that git does not access $HOME'
# strace needs ptrace, which containers and hardened kernels refuse even
# where the binary is installed, so a working run is checked as well as a
# present binary.
-test -n "$(which strace 2>/dev/null)" || {
+command -v strace >/dev/null 2>&1 || {
skip_all='Skipping access validation tests: strace not found'
test_done
exit
diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit
index 56ca807..e35e220 100755
--- a/tests/valgrind/bin/cgit
+++ b/tests/valgrind/bin/cgit
@@ -1,7 +1,10 @@
#!/bin/sh
-# Note that we currently use Git's suppression file and there are variables
-# $GIT_VALGRIND and $CGIT_VALGRIND which point to different places.
+# Stands in for the cgit binary when the suite runs with --valgrind, which is
+# when setup.sh puts this directory ahead of the build on PATH. Git's own
+# suppression file is reused rather than kept in a copy here, so GIT_VALGRIND
+# points into the bundled Git tree while CGIT_VALGRIND points back at this
+# wrapper's home.
exec valgrind -q --error-exitcode=126 \
--suppressions="$GIT_VALGRIND/default.supp" \
--gen-suppressions=all \