aboutsummaryrefslogtreecommitdiff
path: root/tests
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/setup.sh130
-rwxr-xr-xtests/t0001-validate-git-versions.sh28
-rwxr-xr-xtests/t0010-validate-html.sh31
-rwxr-xr-xtests/t0020-validate-cache.sh32
-rwxr-xr-xtests/t0101-index.sh25
-rwxr-xr-xtests/t0102-summary.sh35
-rwxr-xr-xtests/t0103-log.sh33
-rwxr-xr-xtests/t0104-tree.sh33
-rwxr-xr-xtests/t0105-commit.sh41
-rwxr-xr-xtests/t0106-diff.sh21
-rwxr-xr-xtests/t0107-snapshot.sh77
-rwxr-xr-xtests/t0108-patch.sh37
12 files changed, 289 insertions, 234 deletions
diff --git a/tests/setup.sh b/tests/setup.sh
index 81e7220..e3c6c17 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -15,48 +15,46 @@
# run_test 'repo index' 'cgit_url "/" | tidy -e'
# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
-: ${TEST_DIRECTORY=$(pwd)/../git/t}
-TEST_NO_CREATE_REPO=YesPlease
-. "$TEST_DIRECTORY"/test-lib.sh
-
-# Prepend the directory containing cgit to PATH.
-PATH="$(pwd)/../..:$PATH"
+unset CDPATH
mkrepo() {
name=$1
count=$2
- test_create_repo "$name"
- (
- cd "$name"
- n=1
- while test $n -le $count
- do
- echo $n >file-$n
- git add file-$n
- git commit -m "commit $n"
- n=$(expr $n + 1)
- done
- if test "$3" = "testplus"
- then
- echo "hello" >a+b
- git add a+b
- git commit -m "add a+b"
- git branch "1+2"
- fi
- )
+ dir=$PWD
+ test -d "$name" && return
+ printf "Creating testrepo %s\n" "$name"
+ mkdir -p "$name"
+ cd "$name"
+ git init
+ n=1
+ while test $n -le $count
+ do
+ echo $n >file-$n
+ git add file-$n
+ git commit -m "commit $n"
+ n=$(expr $n + 1)
+ done
+ if test "$3" = "testplus"
+ then
+ echo "hello" >a+b
+ git add a+b
+ git commit -m "add a+b"
+ git branch "1+2"
+ fi
+ cd "$dir"
}
setup_repos()
{
- rm -rf cache
- mkdir -p cache
- mkrepo repos/foo 5 >/dev/null
- mkrepo repos/bar 50 >/dev/null
- mkrepo repos/foo+bar 10 testplus >/dev/null
- mkrepo "repos/with space" 2 >/dev/null
- cat >cgitrc <<EOF
+ rm -rf trash/cache
+ mkdir -p trash/cache
+ mkrepo trash/repos/foo 5 >/dev/null
+ mkrepo trash/repos/bar 50 >/dev/null
+ mkrepo trash/repos/foo+bar 10 testplus >/dev/null
+ mkrepo "trash/repos/with space" 2 >/dev/null
+ cat >trash/cgitrc <<EOF
virtual-root=/
-cache-root=$PWD/cache
+cache-root=$PWD/trash/cache
cache-size=1021
snapshots=tar.gz tar.bz zip
@@ -68,33 +66,83 @@ summary-tags=5
clone-url=git://example.org/\$CGIT_REPO_URL.git
repo.url=foo
-repo.path=$PWD/repos/foo/.git
+repo.path=$PWD/trash/repos/foo/.git
# Do not specify a description for this repo, as it then will be assigned
# the constant value "[no description]" (which actually used to cause a
# segfault).
repo.url=bar
-repo.path=$PWD/repos/bar/.git
+repo.path=$PWD/trash/repos/bar/.git
repo.desc=the bar repo
repo.url=foo+bar
-repo.path=$PWD/repos/foo+bar/.git
+repo.path=$PWD/trash/repos/foo+bar/.git
repo.desc=the foo+bar repo
repo.url=with space
-repo.path=$PWD/repos/with space/.git
+repo.path=$PWD/trash/repos/with space/.git
repo.desc=spaced repo
EOF
}
+prepare_tests()
+{
+ setup_repos
+ rm -f test-output.log 2>/dev/null
+ test_count=0
+ test_failed=0
+ echo "[$0]" "$@" >test-output.log
+ echo "$@" "($0)"
+}
+
+tests_done()
+{
+ printf "\n"
+ if test $test_failed -gt 0
+ then
+ printf "test: *** %s failure(s), logfile=%s\n" \
+ $test_failed "$(pwd)/test-output.log"
+ false
+ fi
+}
+
+run_test()
+{
+ bug=0
+ if test "$1" = "BUG"
+ then
+ bug=1
+ shift
+ fi
+ desc=$1
+ script=$2
+ test_count=$(expr $test_count + 1)
+ printf "\ntest %d: name='%s'\n" $test_count "$desc" >>test-output.log
+ printf "test %d: eval='%s'\n" $test_count "$2" >>test-output.log
+ eval "$2" >>test-output.log 2>>test-output.log
+ res=$?
+ printf "test %d: exitcode=%d\n" $test_count $res >>test-output.log
+ if test $res = 0 -a $bug = 0
+ then
+ printf " %2d) %-60s [ok]\n" $test_count "$desc"
+ elif test $res = 0 -a $bug = 1
+ then
+ printf " %2d) %-60s [BUG FIXED]\n" $test_count "$desc"
+ elif test $bug = 1
+ then
+ printf " %2d) %-60s [KNOWN BUG]\n" $test_count "$desc"
+ else
+ test_failed=$(expr $test_failed + 1)
+ printf " %2d) %-60s [failed]\n" $test_count "$desc"
+ fi
+}
+
cgit_query()
{
- CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="$1" cgit
+ CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="$1" "$PWD/../cgit"
}
cgit_url()
{
- CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="url=$1" cgit
+ CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="url=$1" "$PWD/../cgit"
}
-
-test -z "$CGIT_TEST_NO_CREATE_REPOS" && setup_repos
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh
index 754046e..3378358 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -1,36 +1,36 @@
#!/bin/sh
-test_description='Check Git version is correct'
-CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
-test_expect_success 'extract Git version from Makefile' '
+prepare_tests 'Check Git version is correct'
+
+run_test 'extract Git version from Makefile' '
sed -n -e "/^GIT_VER[ ]*=/ {
s/^GIT_VER[ ]*=[ ]*//
p
- }" ../../Makefile >makefile_version
+ }" ../Makefile >trash/makefile_version
'
-test_expect_success 'test Git version matches Makefile' '
- ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
- sed -e "s/GIT_VERSION[ ]*=[ ]*//" >git_version &&
- test_cmp git_version makefile_version
+run_test 'test Git version matches Makefile' '
+ ( cat ../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
+ sed -e "s/GIT_VERSION[ ]*=[ ]*//" >trash/git_version &&
+ diff -u trash/git_version trash/makefile_version
'
-test_expect_success 'test submodule version matches Makefile' '
- if ! test -e ../../git/.git
+run_test 'test submodule version matches Makefile' '
+ if ! test -e ../git/.git
then
echo "git/ is not a Git repository" >&2
else
(
- cd ../.. &&
+ cd .. &&
sm_sha1=$(git ls-files --stage -- git |
sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
cd git &&
git describe --match "v[0-9]*" $sm_sha1
- ) | sed -e "s/^v//" >sm_version &&
- test_cmp sm_version makefile_version
+ ) | sed -e "s/^v//" >trash/sm_version &&
+ diff -u trash/sm_version trash/makefile_version
fi
'
-test_done
+tests_done
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index 5bd0a25..3fe4800 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -1,6 +1,5 @@
#!/bin/sh
-test_description='Validate html with tidy'
. ./setup.sh
@@ -8,9 +7,9 @@ test_url()
{
tidy_opt="-eq"
test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no"
- cgit_url "$1" >tidy-$test_count || return
- sed -ie "1,4d" tidy-$test_count || return
- "$tidy" $tidy_opt tidy-$test_count
+ cgit_url "$1" >trash/tidy-$test_count || return
+ sed -ie "1,4d" trash/tidy-$test_count || return
+ "$tidy" $tidy_opt trash/tidy-$test_count
rc=$?
# tidy returns with exitcode 1 on warnings, 2 on error
@@ -22,19 +21,21 @@ test_url()
fi
}
-tidy=`which tidy 2>/dev/null`
+prepare_tests 'Validate html with tidy'
+
+tidy=`which tidy`
test -n "$tidy" || {
- skip_all='Skipping html validation tests: tidy not found'
- test_done
+ echo "Skipping tests: tidy not found"
+ tests_done
exit
}
-test_expect_success 'index page' 'test_url ""'
-test_expect_success 'foo' 'test_url "foo"'
-test_expect_success 'foo/log' 'test_url "foo/log"'
-test_expect_success 'foo/tree' 'test_url "foo/tree"'
-test_expect_success 'foo/tree/file-1' 'test_url "foo/tree/file-1"'
-test_expect_success 'foo/commit' 'test_url "foo/commit"'
-test_expect_success 'foo/diff' 'test_url "foo/diff"'
+run_test 'index page' 'test_url ""'
+run_test 'foo' 'test_url "foo"'
+run_test 'foo/log' 'test_url "foo/log"'
+run_test 'foo/tree' 'test_url "foo/tree"'
+run_test 'foo/tree/file-1' 'test_url "foo/tree/file-1"'
+run_test 'foo/commit' 'test_url "foo/commit"'
+run_test 'foo/diff' 'test_url "foo/diff"'
-test_done
+tests_done
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index 1910b47..53ec2eb 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -1,12 +1,13 @@
#!/bin/sh
-test_description='Validate cache'
. ./setup.sh
-test_expect_success 'verify cache-size=0' '
+prepare_tests 'Validate cache'
- rm -f cache/* &&
- sed -i -e "s/cache-size=1021$/cache-size=0/" cgitrc &&
+run_test 'verify cache-size=0' '
+
+ rm -f trash/cache/* &&
+ sed -i -e "s/cache-size=1021$/cache-size=0/" trash/cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -20,14 +21,13 @@ test_expect_success 'verify cache-size=0' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- ls cache >output &&
- test_line_count = 0 output
+ test 0 -eq $(ls trash/cache | wc -l)
'
-test_expect_success 'verify cache-size=1' '
+run_test 'verify cache-size=1' '
- rm -f cache/* &&
- sed -i -e "s/cache-size=0$/cache-size=1/" cgitrc &&
+ rm -f trash/cache/* &&
+ sed -i -e "s/cache-size=0$/cache-size=1/" trash/cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -41,14 +41,13 @@ test_expect_success 'verify cache-size=1' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- ls cache >output &&
- test_line_count = 1 output
+ test 1 -eq $(ls trash/cache | wc -l)
'
-test_expect_success 'verify cache-size=1021' '
+run_test 'verify cache-size=1021' '
- rm -f cache/* &&
- sed -i -e "s/cache-size=1$/cache-size=1021/" cgitrc &&
+ rm -f trash/cache/* &&
+ sed -i -e "s/cache-size=1$/cache-size=1021/" trash/cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -62,8 +61,7 @@ test_expect_success 'verify cache-size=1021' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- ls cache >output &&
- test_line_count = 13 output
+ test 13 -eq $(ls trash/cache | wc -l)
'
-test_done
+tests_done
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index 82ef9b0..ab63aca 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -1,17 +1,18 @@
#!/bin/sh
-test_description='Check content on index page'
. ./setup.sh
-test_expect_success 'generate index page' 'cgit_url "" >tmp'
-test_expect_success 'find foo repo' 'grep "foo" tmp'
-test_expect_success 'find foo description' 'grep "\[no description\]" tmp'
-test_expect_success 'find bar repo' 'grep "bar" tmp'
-test_expect_success 'find bar description' 'grep "the bar repo" tmp'
-test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" tmp'
-test_expect_success 'verify foo+bar link' 'grep "/foo+bar/" tmp'
-test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" tmp'
-test_expect_success 'no tree-link' '! grep "foo/tree" tmp'
-test_expect_success 'no log-link' '! grep "foo/log" tmp'
+prepare_tests "Check content on index page"
-test_done
+run_test 'generate index page' 'cgit_url "" >trash/tmp'
+run_test 'find foo repo' 'grep "foo" trash/tmp'
+run_test 'find foo description' 'grep "\[no description\]" trash/tmp'
+run_test 'find bar repo' 'grep "bar" trash/tmp'
+run_test 'find bar description' 'grep "the bar repo" trash/tmp'
+run_test 'find foo+bar repo' 'grep ">foo+bar<" trash/tmp'
+run_test 'verify foo+bar link' 'grep "/foo+bar/" trash/tmp'
+run_test 'verify "with%20space" link' 'grep "/with%20space/" trash/tmp'
+run_test 'no tree-link' '! grep "foo/tree" trash/tmp'
+run_test 'no log-link' '! grep "foo/log" trash/tmp'
+
+tests_done
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index b8864cb..f778cb4 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -1,25 +1,26 @@
#!/bin/sh
-test_description='Check content on summary page'
. ./setup.sh
-test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp'
-test_expect_success 'find commit 1' 'grep "commit 1" tmp'
-test_expect_success 'find commit 5' 'grep "commit 5" tmp'
-test_expect_success 'find branch master' 'grep "master" tmp'
-test_expect_success 'no tags' '! grep "tags" tmp'
-test_expect_success 'clone-url expanded correctly' '
- grep "git://example.org/foo.git" tmp
+prepare_tests "Check content on summary page"
+
+run_test 'generate foo summary' 'cgit_url "foo" >trash/tmp'
+run_test 'find commit 1' 'grep "commit 1" trash/tmp'
+run_test 'find commit 5' 'grep "commit 5" trash/tmp'
+run_test 'find branch master' 'grep "master" trash/tmp'
+run_test 'no tags' '! grep "tags" trash/tmp'
+run_test 'clone-url expanded correctly' '
+ grep "git://example.org/foo.git" trash/tmp
'
-test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp'
-test_expect_success 'no commit 45' '! grep "commit 45" tmp'
-test_expect_success 'find commit 46' 'grep "commit 46" tmp'
-test_expect_success 'find commit 50' 'grep "commit 50" tmp'
-test_expect_success 'find branch master' 'grep "master" tmp'
-test_expect_success 'no tags' '! grep "tags" tmp'
-test_expect_success 'clone-url expanded correctly' '
- grep "git://example.org/bar.git" tmp
+run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp'
+run_test 'no commit 45' '! grep "commit 45" trash/tmp'
+run_test 'find commit 46' 'grep "commit 46" trash/tmp'
+run_test 'find commit 50' 'grep "commit 50" trash/tmp'
+run_test 'find branch master' 'grep "master" trash/tmp'
+run_test 'no tags' '! grep "tags" trash/tmp'
+run_test 'clone-url expanded correctly' '
+ grep "git://example.org/bar.git" trash/tmp
'
-test_done
+tests_done
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index bdf1435..67fcba0 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -1,24 +1,25 @@
#!/bin/sh
-test_description='Check content on log page'
. ./setup.sh
-test_expect_success 'generate foo/log' 'cgit_url "foo/log" >tmp'
-test_expect_success 'find commit 1' 'grep "commit 1" tmp'
-test_expect_success 'find commit 5' 'grep "commit 5" tmp'
+prepare_tests "Check content on log page"
-test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp'
-test_expect_success 'find commit 1' 'grep "commit 1" tmp'
-test_expect_success 'find commit 50' 'grep "commit 50" tmp'
+run_test 'generate foo/log' 'cgit_url "foo/log" >trash/tmp'
+run_test 'find commit 1' 'grep "commit 1" trash/tmp'
+run_test 'find commit 5' 'grep "commit 5" trash/tmp'
-test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' '
- cgit_url "with+space/log&qt=grep&q=commit+1" >tmp
+run_test 'generate bar/log' 'cgit_url "bar/log" >trash/tmp'
+run_test 'find commit 1' 'grep "commit 1" trash/tmp'
+run_test 'find commit 50' 'grep "commit 50" trash/tmp'
+
+run_test 'generate "with%20space/log?qt=grep&q=commit+1"' '
+ cgit_url "with+space/log&qt=grep&q=commit+1" >trash/tmp
'
-test_expect_success 'find commit 1' 'grep "commit 1" tmp'
-test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" tmp'
-test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&amp;q=commit+1" tmp'
-test_expect_success 'no links with space in path' '! grep "href=./with space/" tmp'
-test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp'
-test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp'
+run_test 'find commit 1' 'grep "commit 1" trash/tmp'
+run_test 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" trash/tmp'
+run_test 'find link with + in arg' 'grep "/log/?qt=grep&amp;q=commit+1" trash/tmp'
+run_test 'no links with space in path' '! grep "href=./with space/" trash/tmp'
+run_test 'no links with space in arg' '! grep "q=commit 1" trash/tmp'
+run_test 'commit 2 is not visible' '! grep "commit 2" trash/tmp'
-test_done
+tests_done
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index 100b026..7aa3b8d 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -1,32 +1,33 @@
#!/bin/sh
-test_description='Check content on tree page'
. ./setup.sh
-test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp'
-test_expect_success 'find file-1' 'grep "file-1" tmp'
-test_expect_success 'find file-50' 'grep "file-50" tmp'
+prepare_tests "Check content on tree page"
-test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >tmp'
+run_test 'generate bar/tree' 'cgit_url "bar/tree" >trash/tmp'
+run_test 'find file-1' 'grep "file-1" trash/tmp'
+run_test 'find file-50' 'grep "file-50" trash/tmp'
-test_expect_success 'find line 1' '
- grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" tmp
+run_test 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp'
+
+run_test 'find line 1' '
+ grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp
'
-test_expect_success 'no line 2' '
- ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" tmp
+run_test 'no line 2' '
+ ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
'
-test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp'
+run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'
-test_expect_success 'verify a+b link' '
- grep "/foo+bar/tree/a+b" tmp
+run_test 'verify a+b link' '
+ grep "/foo+bar/tree/a+b" trash/tmp
'
-test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >tmp'
+run_test 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >trash/tmp'
-test_expect_success 'verify a+b?h=1+2 link' '
- grep "/foo+bar/tree/a+b?h=1%2b2" tmp
+run_test 'verify a+b?h=1+2 link' '
+ grep "/foo+bar/tree/a+b?h=1%2b2" trash/tmp
'
-test_done
+tests_done
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh
index 9cdf55c..31b554b 100755
--- a/tests/t0105-commit.sh
+++ b/tests/t0105-commit.sh
@@ -1,36 +1,37 @@
#!/bin/sh
-test_description='Check content on commit page'
. ./setup.sh
-test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >tmp'
-test_expect_success 'find tree link' 'grep "<a href=./foo/tree/.>" tmp'
-test_expect_success 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" tmp'
+prepare_tests "Check content on commit page"
-test_expect_success 'find commit subject' '
- grep "<div class=.commit-subject.>commit 5<" tmp
+run_test 'generate foo/commit' 'cgit_url "foo/commit" >trash/tmp'
+run_test 'find tree link' 'grep "<a href=./foo/tree/.>" trash/tmp'
+run_test 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" trash/tmp'
+
+run_test 'find commit subject' '
+ grep "<div class=.commit-subject.>commit 5<" trash/tmp
'
-test_expect_success 'find commit msg' 'grep "<div class=.commit-msg.></div>" tmp'
-test_expect_success 'find diffstat' 'grep "<table summary=.diffstat. class=.diffstat.>" tmp'
+run_test 'find commit msg' 'grep "<div class=.commit-msg.></div>" trash/tmp'
+run_test 'find diffstat' 'grep "<table summary=.diffstat. class=.diffstat.>" trash/tmp'
-test_expect_success 'find diff summary' '
- grep "1 files changed, 1 insertions, 0 deletions" tmp
+run_test 'find diff summary' '
+ grep "1 files changed, 1 insertions, 0 deletions" trash/tmp
'
-test_expect_success 'get root commit' '
- root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) &&
- cgit_url "foo/commit&id=$root" >tmp &&
- grep "</html>" tmp
+run_test 'get root commit' '
+ root=$(cd trash/repos/foo && git rev-list --reverse HEAD | head -1) &&
+ cgit_url "foo/commit&id=$root" >trash/tmp &&
+ grep "</html>" trash/tmp
'
-test_expect_success 'root commit contains diffstat' '
- grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" tmp
+run_test 'root commit contains diffstat' '
+ grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" trash/tmp
'
-test_expect_success 'root commit contains diff' '
- grep ">diff --git a/file-1 b/file-1<" tmp &&
- grep "<div class=.add.>+1</div>" tmp
+run_test 'root commit contains diff' '
+ grep ">diff --git a/file-1 b/file-1<" trash/tmp &&
+ grep "<div class=.add.>+1</div>" trash/tmp
'
-test_done
+tests_done
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index 82b645e..eee0c8c 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -1,19 +1,20 @@
#!/bin/sh
-test_description='Check content on diff page'
. ./setup.sh
-test_expect_success 'generate foo/diff' 'cgit_url "foo/diff" >tmp'
-test_expect_success 'find diff header' 'grep "a/file-5 b/file-5" tmp'
-test_expect_success 'find blob link' 'grep "<a href=./foo/tree/file-5?id=" tmp'
-test_expect_success 'find added file' 'grep "new file mode 100644" tmp'
+prepare_tests "Check content on diff page"
-test_expect_success 'find hunk header' '
- grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" tmp
+run_test 'generate foo/diff' 'cgit_url "foo/diff" >trash/tmp'
+run_test 'find diff header' 'grep "a/file-5 b/file-5" trash/tmp'
+run_test 'find blob link' 'grep "<a href=./foo/tree/file-5?id=" trash/tmp'
+run_test 'find added file' 'grep "new file mode 100644" trash/tmp'
+
+run_test 'find hunk header' '
+ grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" trash/tmp
'
-test_expect_success 'find added line' '
- grep "<div class=.add.>+5</div>" tmp
+run_test 'find added line' '
+ grep "<div class=.add.>+5</div>" trash/tmp
'
-test_done
+tests_done
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 4fbe45e..132d2e9 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -1,76 +1,77 @@
#!/bin/sh
-test_description='Verify snapshot'
. ./setup.sh
-test_expect_success 'get foo/snapshot/master.tar.gz' '
- cgit_url "foo/snapshot/master.tar.gz" >tmp
+prepare_tests "Verify snapshot"
+
+run_test 'get foo/snapshot/master.tar.gz' '
+ cgit_url "foo/snapshot/master.tar.gz" >trash/tmp
'
-test_expect_success 'check html headers' '
- head -n 1 tmp |
+run_test 'check html headers' '
+ head -n 1 trash/tmp |
grep "Content-Type: application/x-gzip" &&
- head -n 2 tmp |
+ head -n 2 trash/tmp |
grep "Content-Disposition: inline; filename=.master.tar.gz."
'
-test_expect_success 'strip off the header lines' '
- tail -n +6 tmp > master.tar.gz
+run_test 'strip off the header lines' '
+ tail -n +6 trash/tmp > trash/master.tar.gz
'
-test_expect_success 'verify gzip format' '
- gunzip --test master.tar.gz
+run_test 'verify gzip format' '
+ gunzip --test trash/master.tar.gz
'
-test_expect_success 'untar' '
- rm -rf master &&
- tar -xf master.tar.gz
+run_test 'untar' '
+ rm -rf trash/master &&
+ tar -xf trash/master.tar.gz -C trash
'
-test_expect_success 'count files' '
- ls master/ >output &&
- test_line_count = 5 output
+run_test 'count files' '
+ c=$(ls -1 trash/master/ | wc -l) &&
+ test $c = 5
'
-test_expect_success 'verify untarred file-5' '
- grep "^5$" master/file-5 &&
- test_line_count = 1 master/file-5
+run_test 'verify untarred file-5' '
+ grep "^5$" trash/master/file-5 &&
+ test $(cat trash/master/file-5 | wc -l) = 1
'
-test_expect_success 'get foo/snapshot/master.zip' '
- cgit_url "foo/snapshot/master.zip" >tmp
+run_test 'get foo/snapshot/master.zip' '
+ cgit_url "foo/snapshot/master.zip" >trash/tmp
'
-test_expect_success 'check HTML headers (zip)' '
- head -n 1 tmp |
+run_test 'check HTML headers (zip)' '
+ head -n 1 trash/tmp |
grep "Content-Type: application/x-zip" &&
- head -n 2 tmp |
+ head -n 2 trash/tmp |
grep "Content-Disposition: inline; filename=.master.zip."
'
-test_expect_success 'strip off the header lines (zip)' '
- tail -n +6 tmp >master.zip
+run_test 'strip off the header lines (zip)' '
+ tail -n +6 trash/tmp >trash/master.zip
'
-test_expect_success 'verify zip format' '
- unzip -t master.zip
+run_test 'verify zip format' '
+ unzip -t trash/master.zip
'
-test_expect_success 'unzip' '
- rm -rf master &&
- unzip master.zip
+run_test 'unzip' '
+ rm -rf trash/master &&
+ unzip trash/master.zip -d trash
'
-test_expect_success 'count files (zip)' '
- ls master/ >output &&
- test_line_count = 5 output
+run_test 'count files (zip)' '
+ c=$(ls -1 trash/master/ | wc -l) &&
+ test $c = 5
'
-test_expect_success 'verify unzipped file-5' '
- grep "^5$" master/file-5 &&
- test_line_count = 1 master/file-5
+run_test 'verify unzipped file-5' '
+ grep "^5$" trash/master/file-5 &&
+ test $(cat trash/master/file-5 | wc -l) = 1
'
-test_done
+tests_done
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index 3b5bae4..f92f69c 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -1,38 +1,39 @@
#!/bin/sh
-test_description='Check content on patch page'
. ./setup.sh
-test_expect_success 'generate foo/patch' '
- cgit_query "url=foo/patch" >tmp
+prepare_tests "Check content on patch page"
+
+run_test 'generate foo/patch' '
+ cgit_query "url=foo/patch" >trash/tmp
'
-test_expect_success 'find `From:` line' '
- grep "^From: " tmp
+run_test 'find `From:` line' '
+ grep "^From: " trash/tmp
'
-test_expect_success 'find `Date:` line' '
- grep "^Date: " tmp
+run_test 'find `Date:` line' '
+ grep "^Date: " trash/tmp
'
-test_expect_success 'find `Subject:` line' '
- grep "^Subject: commit 5" tmp
+run_test 'find `Subject:` line' '
+ grep "^Subject: commit 5" trash/tmp
'
-test_expect_success 'find `cgit` signature' '
- tail -1 tmp | grep "^cgit"
+run_test 'find `cgit` signature' '
+ tail -1 trash/tmp | grep "^cgit"
'
-test_expect_success 'find initial commit' '
- root=$(git --git-dir="$PWD/repos/foo/.git" rev-list HEAD | tail -1)
+run_test 'find initial commit' '
+ root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1)
'
-test_expect_success 'generate patch for initial commit' '
- cgit_query "url=foo/patch&id=$root" >tmp
+run_test 'generate patch for initial commit' '
+ cgit_query "url=foo/patch&id=$root" >trash/tmp
'
-test_expect_success 'find `cgit` signature' '
- tail -1 tmp | grep "^cgit"
+run_test 'find `cgit` signature' '
+ tail -1 trash/tmp | grep "^cgit"
'
-test_done
+tests_done