diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore4
-rw-r--r--tests/Makefile2
-rwxr-xr-xtests/setup.sh25
-rwxr-xr-xtests/t0001-git-version.sh9
-rwxr-xr-xtests/t0109-patch.sh4
-rwxr-xr-xtests/t0204-limits.sh2
-rwxr-xr-xtests/t0401-serve.sh2
7 files changed, 33 insertions, 15 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index f2fe0e2..3f7a7ba 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,4 +1,4 @@
-trash\ directory.t*
-test-results
+trash/
+results/
__pycache__/
.DS_Store
diff --git a/tests/Makefile b/tests/Makefile
index 7a8beb1..a73ad86 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -25,7 +25,7 @@ $(TESTS):
@'$(SHELL_PATH_SQ)' $@ $(CGIT_TEST_OPTS)
clean:
- $(RM) -r 'trash directory'.* test-results
+ $(RM) -r trash results
# Each test is named after a file that already exists, so without this make
# would decide there is nothing to do and run none of them.
diff --git a/tests/setup.sh b/tests/setup.sh
index 44751b4..757ae04 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -12,7 +12,11 @@
# that none holds a newline of its own.
LF='
'
-test_argv=
+# Trash directories are collected under one trash/ rather than left beside
+# the scripts, which keeps the ignore and clean rules to a single plain
+# name. The option is seeded ahead of the real arguments so one given on
+# the command line still wins.
+test_argv="${LF}--root=trash"
while test $# != 0
do
@@ -40,19 +44,32 @@ IFS=$OLDIFS
TEST_NO_CREATE_REPO=YesPlease
. "$TEST_DIRECTORY"/test-lib.sh
+# The library spells its results directory test-results and derives these
+# variables before it can be told otherwise, so they are re-pointed here and
+# every count lands under the plainer results/ instead. The rarely used
+# --tee and --stress options write their raw logs before this line and keep
+# the library's own name.
+TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/results"
+TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX"
+TEST_RESULTS_SAN_DIR="$TEST_RESULTS_BASE.$TEST_RESULTS_SAN_DIR_SFX"
+
+# The library has moved into the trash directory by now, so everything the
+# tests reach outside it is anchored to TEST_OUTPUT_DIRECTORY, which still
+# names this directory whatever depth the trash sits at.
+
# The tests run cgit by name, so the binary just built has to come ahead of any
# copy already installed. Under Valgrind the wrappers take that place instead.
if test -n "$cgit_valgrind"
then
GIT_VALGRIND="$TEST_DIRECTORY/valgrind"
- CGIT_VALGRIND=$(cd ../valgrind && pwd)
+ CGIT_VALGRIND=$(cd "$TEST_OUTPUT_DIRECTORY/valgrind" && pwd)
PATH="$CGIT_VALGRIND/bin:$PATH"
export GIT_VALGRIND CGIT_VALGRIND
else
- PATH="$(pwd)/../../build:$PATH"
+ PATH="$TEST_OUTPUT_DIRECTORY/../build:$PATH"
fi
-FILTER_DIRECTORY=$(cd ../filters && pwd)
+FILTER_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/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.
diff --git a/tests/t0001-git-version.sh b/tests/t0001-git-version.sh
index 8436812..7dd9c40 100755
--- a/tests/t0001-git-version.sh
+++ b/tests/t0001-git-version.sh
@@ -20,14 +20,15 @@ test_expect_success 'extract Git version from Makefile' '
sed -n -e "/^GIT_VERSION[ ]*=/ {
s/^GIT_VERSION[ ]*=[ ]*//
p
- }" ../../Makefile >makefile_version
+ }" "$TEST_OUTPUT_DIRECTORY/../Makefile" >makefile_version
'
# Git's GIT-VERSION-GEN script applies "s/-/./g" to the version string on its
# way into the GIT-VERSION-FILE, so the same has to be done to the version in
# the Makefile before the two can be compared.
test_expect_success 'test Git version matches Makefile' '
- ( cat ../../vendor/git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
+ ( cat "$TEST_OUTPUT_DIRECTORY/../vendor/git/GIT-VERSION-FILE" ||
+ echo "No GIT-VERSION-FILE" ) |
sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version &&
sed -e "s/-/./g" makefile_version >makefile_git_version &&
test_cmp git_version makefile_git_version
@@ -36,12 +37,12 @@ test_expect_success 'test Git version matches Makefile' '
# A tree unpacked from a tarball has no submodule pin to describe, so there is
# nothing to compare against and the test says so rather than failing.
test_expect_success 'test submodule version matches Makefile' '
- if ! test -e ../../vendor/git/.git
+ if ! test -e "$TEST_OUTPUT_DIRECTORY/../vendor/git/.git"
then
echo "vendor/git/ is not a Git repository" >&2
else
(
- cd ../.. &&
+ cd "$TEST_OUTPUT_DIRECTORY/.." &&
submodule_oid=$(git ls-files --stage -- vendor/git |
sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
cd vendor/git &&
diff --git a/tests/t0109-patch.sh b/tests/t0109-patch.sh
index 3d38e55..ae4dc83 100755
--- a/tests/t0109-patch.sh
+++ b/tests/t0109-patch.sh
@@ -31,7 +31,7 @@ test_expect_success 'find `cgit` signature' '
'
test_expect_success 'compare with output of git-format-patch(1)' '
- CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../build/VERSION) &&
+ CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" "$TEST_OUTPUT_DIRECTORY/../build/VERSION") &&
git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 &&
strip_headers <tmp >tmp_ &&
test_cmp tmp_ tmp2
@@ -60,7 +60,7 @@ test_expect_success 'find `cgit` signature' '
'
test_expect_success 'compare with output of git-format-patch(1)' '
- CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../build/VERSION) &&
+ CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" "$TEST_OUTPUT_DIRECTORY/../build/VERSION") &&
git --git-dir="$PWD/repos/foo/.git" format-patch -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 &&
strip_headers <tmp >tmp_ &&
test_cmp tmp_ tmp2
diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh
index d35dc69..6591106 100755
--- a/tests/t0204-limits.sh
+++ b/tests/t0204-limits.sh
@@ -171,7 +171,7 @@ test_expect_success LUA 'highlight filter passes text through without scintillua
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
- echo "source-filter=lua:$(cd ../../custom/extensions && pwd)/syntax-highlight.lua" &&
+ echo "source-filter=lua:$(cd "$TEST_OUTPUT_DIRECTORY/../custom/extensions" && pwd)/syntax-highlight.lua" &&
echo "repo.url=limits" &&
echo "repo.path=$PWD/repos/limits/.git"
} >hlrc &&
diff --git a/tests/t0401-serve.sh b/tests/t0401-serve.sh
index f7244a2..5a2b9b6 100755
--- a/tests/t0401-serve.sh
+++ b/tests/t0401-serve.sh
@@ -18,7 +18,7 @@ command -v python3 >/dev/null 2>&1 || {
}
test_expect_success 'CGI headers and body are split at the first blank line' '
- python3 "$PWD/../serve-split-check.py" "$PWD/../.."
+ python3 "$TEST_OUTPUT_DIRECTORY/serve-split-check.py" "$TEST_OUTPUT_DIRECTORY/.."
'
test_done