aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-04-01 15:09:05 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2013-04-08 22:27:11 +0200
commitc95cc5ec56dbb7394015eb18201403be6d80f69b (patch)
tree7014b96a1a1408b5291532c0c442082aba693a80 /tests
parent8a92df033e974af6338b530a0d78d1bdb0b0f918 (diff)
downloadpkg-cgit-c95cc5ec56dbb7394015eb18201403be6d80f69b.zip
pkg-cgit-c95cc5ec56dbb7394015eb18201403be6d80f69b.tar.gz
pkg-cgit-c95cc5ec56dbb7394015eb18201403be6d80f69b.tar.bz2
tests: use Git's test framework
This allows tests to run in parallel as well as letting us use "prove" or another TAP harness to run the tests. Git's test framework requires Git to be fully built before letting any tests run, so add a new target to the top-level Makefile which builds all of Git instead of just libgit.a and make the "test" target depend on that. Signed-off-by: John Keeping <john@keeping.me.uk>
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, 234 insertions, 289 deletions
diff --git a/tests/setup.sh b/tests/setup.sh
index e3c6c17..81e7220 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -15,46 +15,48 @@
# run_test 'repo index' 'cgit_url "/" | tidy -e'
# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
-unset CDPATH
+: ${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"
mkrepo() {
name=$1
count=$2
- 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"
+ 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
+ )
}
setup_repos()
{
- 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
+ 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
virtual-root=/
-cache-root=$PWD/trash/cache
+cache-root=$PWD/cache
cache-size=1021
snapshots=tar.gz tar.bz zip
@@ -66,83 +68,33 @@ summary-tags=5
clone-url=git://example.org/\$CGIT_REPO_URL.git
repo.url=foo
-repo.path=$PWD/trash/repos/foo/.git
+repo.path=$PWD/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/trash/repos/bar/.git
+repo.path=$PWD/repos/bar/.git
repo.desc=the bar repo
repo.url=foo+bar
-repo.path=$PWD/trash/repos/foo+bar/.git
+repo.path=$PWD/repos/foo+bar/.git
repo.desc=the foo+bar repo
repo.url=with space
-repo.path=$PWD/trash/repos/with space/.git
+repo.path=$PWD/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/trash/cgitrc" QUERY_STRING="$1" "$PWD/../cgit"
+ CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="$1" cgit
}
cgit_url()
{
- CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="url=$1" "$PWD/../cgit"
+ CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="url=$1" 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 3378358..754046e 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
-prepare_tests 'Check Git version is correct'
-
-run_test 'extract Git version from Makefile' '
+test_expect_success 'extract Git version from Makefile' '
sed -n -e "/^GIT_VER[ ]*=/ {
s/^GIT_VER[ ]*=[ ]*//
p
- }" ../Makefile >trash/makefile_version
+ }" ../../Makefile >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 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 submodule version matches Makefile' '
- if ! test -e ../git/.git
+test_expect_success '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//" >trash/sm_version &&
- diff -u trash/sm_version trash/makefile_version
+ ) | sed -e "s/^v//" >sm_version &&
+ test_cmp sm_version makefile_version
fi
'
-tests_done
+test_done
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index 3fe4800..5bd0a25 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+test_description='Validate html with tidy'
. ./setup.sh
@@ -7,9 +8,9 @@ test_url()
{
tidy_opt="-eq"
test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no"
- cgit_url "$1" >trash/tidy-$test_count || return
- sed -ie "1,4d" trash/tidy-$test_count || return
- "$tidy" $tidy_opt trash/tidy-$test_count
+ cgit_url "$1" >tidy-$test_count || return
+ sed -ie "1,4d" tidy-$test_count || return
+ "$tidy" $tidy_opt tidy-$test_count
rc=$?
# tidy returns with exitcode 1 on warnings, 2 on error
@@ -21,21 +22,19 @@ test_url()
fi
}
-prepare_tests 'Validate html with tidy'
-
-tidy=`which tidy`
+tidy=`which tidy 2>/dev/null`
test -n "$tidy" || {
- echo "Skipping tests: tidy not found"
- tests_done
+ skip_all='Skipping html validation tests: tidy not found'
+ test_done
exit
}
-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_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"'
-tests_done
+test_done
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index 53ec2eb..1910b47 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -1,13 +1,12 @@
#!/bin/sh
+test_description='Validate cache'
. ./setup.sh
-prepare_tests 'Validate cache'
+test_expect_success 'verify cache-size=0' '
-run_test 'verify cache-size=0' '
-
- rm -f trash/cache/* &&
- sed -i -e "s/cache-size=1021$/cache-size=0/" trash/cgitrc &&
+ rm -f cache/* &&
+ sed -i -e "s/cache-size=1021$/cache-size=0/" cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -21,13 +20,14 @@ run_test 'verify cache-size=0' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 0 -eq $(ls trash/cache | wc -l)
+ ls cache >output &&
+ test_line_count = 0 output
'
-run_test 'verify cache-size=1' '
+test_expect_success 'verify cache-size=1' '
- rm -f trash/cache/* &&
- sed -i -e "s/cache-size=0$/cache-size=1/" trash/cgitrc &&
+ rm -f cache/* &&
+ sed -i -e "s/cache-size=0$/cache-size=1/" cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -41,13 +41,14 @@ run_test 'verify cache-size=1' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 1 -eq $(ls trash/cache | wc -l)
+ ls cache >output &&
+ test_line_count = 1 output
'
-run_test 'verify cache-size=1021' '
+test_expect_success 'verify cache-size=1021' '
- rm -f trash/cache/* &&
- sed -i -e "s/cache-size=1$/cache-size=1021/" trash/cgitrc &&
+ rm -f cache/* &&
+ sed -i -e "s/cache-size=1$/cache-size=1021/" cgitrc &&
cgit_url "" &&
cgit_url "foo" &&
cgit_url "foo/refs" &&
@@ -61,7 +62,8 @@ run_test 'verify cache-size=1021' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 13 -eq $(ls trash/cache | wc -l)
+ ls cache >output &&
+ test_line_count = 13 output
'
-tests_done
+test_done
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index ab63aca..82ef9b0 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -1,18 +1,17 @@
#!/bin/sh
+test_description='Check content on index page'
. ./setup.sh
-prepare_tests "Check content on index page"
+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'
-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
+test_done
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index f778cb4..b8864cb 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -1,26 +1,25 @@
#!/bin/sh
+test_description='Check content on summary page'
. ./setup.sh
-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 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
'
-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_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
'
-tests_done
+test_done
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index 67fcba0..bdf1435 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -1,25 +1,24 @@
#!/bin/sh
+test_description='Check content on log page'
. ./setup.sh
-prepare_tests "Check content on log page"
+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'
-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 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 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 'generate "with%20space/log?qt=grep&q=commit+1"' '
+ cgit_url "with+space/log&qt=grep&q=commit+1" >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_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'
-tests_done
+test_done
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index 7aa3b8d..100b026 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -1,33 +1,32 @@
#!/bin/sh
+test_description='Check content on tree page'
. ./setup.sh
-prepare_tests "Check content on tree page"
+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'
-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 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >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 'find line 1' '
+ grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" tmp
'
-run_test 'no line 2' '
- ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
+test_expect_success 'no line 2' '
+ ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" tmp
'
-run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'
+test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp'
-run_test 'verify a+b link' '
- grep "/foo+bar/tree/a+b" trash/tmp
+test_expect_success 'verify a+b link' '
+ grep "/foo+bar/tree/a+b" tmp
'
-run_test 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >trash/tmp'
+test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&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_expect_success 'verify a+b?h=1+2 link' '
+ grep "/foo+bar/tree/a+b?h=1%2b2" tmp
'
-tests_done
+test_done
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh
index 31b554b..9cdf55c 100755
--- a/tests/t0105-commit.sh
+++ b/tests/t0105-commit.sh
@@ -1,37 +1,36 @@
#!/bin/sh
+test_description='Check content on commit page'
. ./setup.sh
-prepare_tests "Check content on commit page"
+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'
-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 subject' '
+ grep "<div class=.commit-subject.>commit 5<" 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 commit msg' 'grep "<div class=.commit-msg.></div>" tmp'
+test_expect_success 'find diffstat' 'grep "<table summary=.diffstat. class=.diffstat.>" tmp'
-run_test 'find diff summary' '
- grep "1 files changed, 1 insertions, 0 deletions" trash/tmp
+test_expect_success 'find diff summary' '
+ grep "1 files changed, 1 insertions, 0 deletions" 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 '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 '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 diffstat' '
+ grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" 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_expect_success 'root commit contains diff' '
+ grep ">diff --git a/file-1 b/file-1<" tmp &&
+ grep "<div class=.add.>+1</div>" tmp
'
-tests_done
+test_done
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index eee0c8c..82b645e 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -1,20 +1,19 @@
#!/bin/sh
+test_description='Check content on diff page'
. ./setup.sh
-prepare_tests "Check content on diff page"
+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'
-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 hunk header' '
+ grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" tmp
'
-run_test 'find added line' '
- grep "<div class=.add.>+5</div>" trash/tmp
+test_expect_success 'find added line' '
+ grep "<div class=.add.>+5</div>" tmp
'
-tests_done
+test_done
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 132d2e9..4fbe45e 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -1,77 +1,76 @@
#!/bin/sh
+test_description='Verify snapshot'
. ./setup.sh
-prepare_tests "Verify snapshot"
-
-run_test 'get foo/snapshot/master.tar.gz' '
- cgit_url "foo/snapshot/master.tar.gz" >trash/tmp
+test_expect_success 'get foo/snapshot/master.tar.gz' '
+ cgit_url "foo/snapshot/master.tar.gz" >tmp
'
-run_test 'check html headers' '
- head -n 1 trash/tmp |
+test_expect_success 'check html headers' '
+ head -n 1 tmp |
grep "Content-Type: application/x-gzip" &&
- head -n 2 trash/tmp |
+ head -n 2 tmp |
grep "Content-Disposition: inline; filename=.master.tar.gz."
'
-run_test 'strip off the header lines' '
- tail -n +6 trash/tmp > trash/master.tar.gz
+test_expect_success 'strip off the header lines' '
+ tail -n +6 tmp > master.tar.gz
'
-run_test 'verify gzip format' '
- gunzip --test trash/master.tar.gz
+test_expect_success 'verify gzip format' '
+ gunzip --test master.tar.gz
'
-run_test 'untar' '
- rm -rf trash/master &&
- tar -xf trash/master.tar.gz -C trash
+test_expect_success 'untar' '
+ rm -rf master &&
+ tar -xf master.tar.gz
'
-run_test 'count files' '
- c=$(ls -1 trash/master/ | wc -l) &&
- test $c = 5
+test_expect_success 'count files' '
+ ls master/ >output &&
+ test_line_count = 5 output
'
-run_test 'verify untarred file-5' '
- grep "^5$" trash/master/file-5 &&
- test $(cat trash/master/file-5 | wc -l) = 1
+test_expect_success 'verify untarred file-5' '
+ grep "^5$" master/file-5 &&
+ test_line_count = 1 master/file-5
'
-run_test 'get foo/snapshot/master.zip' '
- cgit_url "foo/snapshot/master.zip" >trash/tmp
+test_expect_success 'get foo/snapshot/master.zip' '
+ cgit_url "foo/snapshot/master.zip" >tmp
'
-run_test 'check HTML headers (zip)' '
- head -n 1 trash/tmp |
+test_expect_success 'check HTML headers (zip)' '
+ head -n 1 tmp |
grep "Content-Type: application/x-zip" &&
- head -n 2 trash/tmp |
+ head -n 2 tmp |
grep "Content-Disposition: inline; filename=.master.zip."
'
-run_test 'strip off the header lines (zip)' '
- tail -n +6 trash/tmp >trash/master.zip
+test_expect_success 'strip off the header lines (zip)' '
+ tail -n +6 tmp >master.zip
'
-run_test 'verify zip format' '
- unzip -t trash/master.zip
+test_expect_success 'verify zip format' '
+ unzip -t master.zip
'
-run_test 'unzip' '
- rm -rf trash/master &&
- unzip trash/master.zip -d trash
+test_expect_success 'unzip' '
+ rm -rf master &&
+ unzip master.zip
'
-run_test 'count files (zip)' '
- c=$(ls -1 trash/master/ | wc -l) &&
- test $c = 5
+test_expect_success 'count files (zip)' '
+ ls master/ >output &&
+ test_line_count = 5 output
'
-run_test 'verify unzipped file-5' '
- grep "^5$" trash/master/file-5 &&
- test $(cat trash/master/file-5 | wc -l) = 1
+test_expect_success 'verify unzipped file-5' '
+ grep "^5$" master/file-5 &&
+ test_line_count = 1 master/file-5
'
-tests_done
+test_done
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index f92f69c..3b5bae4 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -1,39 +1,38 @@
#!/bin/sh
+test_description='Check content on patch page'
. ./setup.sh
-prepare_tests "Check content on patch page"
-
-run_test 'generate foo/patch' '
- cgit_query "url=foo/patch" >trash/tmp
+test_expect_success 'generate foo/patch' '
+ cgit_query "url=foo/patch" >tmp
'
-run_test 'find `From:` line' '
- grep "^From: " trash/tmp
+test_expect_success 'find `From:` line' '
+ grep "^From: " tmp
'
-run_test 'find `Date:` line' '
- grep "^Date: " trash/tmp
+test_expect_success 'find `Date:` line' '
+ grep "^Date: " tmp
'
-run_test 'find `Subject:` line' '
- grep "^Subject: commit 5" trash/tmp
+test_expect_success 'find `Subject:` line' '
+ grep "^Subject: commit 5" tmp
'
-run_test 'find `cgit` signature' '
- tail -1 trash/tmp | grep "^cgit"
+test_expect_success 'find `cgit` signature' '
+ tail -1 tmp | grep "^cgit"
'
-run_test 'find initial commit' '
- root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1)
+test_expect_success 'find initial commit' '
+ root=$(git --git-dir="$PWD/repos/foo/.git" rev-list HEAD | tail -1)
'
-run_test 'generate patch for initial commit' '
- cgit_query "url=foo/patch&id=$root" >trash/tmp
+test_expect_success 'generate patch for initial commit' '
+ cgit_query "url=foo/patch&id=$root" >tmp
'
-run_test 'find `cgit` signature' '
- tail -1 trash/tmp | grep "^cgit"
+test_expect_success 'find `cgit` signature' '
+ tail -1 tmp | grep "^cgit"
'
-tests_done
+test_done