[PATCH 01/12] tests: use Git test functions directly
John Keeping
john at keeping.me.uk
Mon Apr 8 21:12:30 CEST 2013
This removes the run_test and tests_done wrapper functions, changing
everywhere they were used to use the correct Git test functions instead.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 18 ------------------
tests/t0001-validate-git-versions.sh | 8 ++++----
tests/t0010-validate-html.sh | 18 +++++++++---------
tests/t0020-validate-cache.sh | 8 ++++----
tests/t0101-index.sh | 22 +++++++++++-----------
tests/t0102-summary.sh | 28 ++++++++++++++--------------
tests/t0103-log.sh | 28 ++++++++++++++--------------
tests/t0104-tree.sh | 22 +++++++++++-----------
tests/t0105-commit.sh | 22 +++++++++++-----------
tests/t0106-diff.sh | 14 +++++++-------
tests/t0107-snapshot.sh | 30 +++++++++++++++---------------
tests/t0108-patch.sh | 18 +++++++++---------
12 files changed, 109 insertions(+), 127 deletions(-)
diff --git a/tests/setup.sh b/tests/setup.sh
index 015d55a..774056b 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -91,24 +91,6 @@ prepare_tests()
setup_repos
}
-tests_done()
-{
- test_done
-}
-
-run_test()
-{
- func=test_expect_success
- if test "$1" = "BUG"
- then
- func=test_expect_failure
- shift
- fi
- desc=$1
- script=$2
- $func "$desc" "$script"
-}
-
cgit_query()
{
CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="$1" "$PWD/../../cgit"
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh
index 444e4a0..02cb35a 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -5,20 +5,20 @@ test_description='Check Git version is correct'
prepare_tests
-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
'
-run_test 'test Git version matches Makefile' '
+test_expect_success '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
'
-run_test 'test submodule version matches Makefile' '
+test_expect_success 'test submodule version matches Makefile' '
if ! test -e ../../git/.git
then
echo "git/ is not a Git repository" >&2
@@ -34,4 +34,4 @@ run_test 'test submodule version matches Makefile' '
fi
'
-tests_done
+test_done
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index d3fa14a..9cc0fdd 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -31,12 +31,12 @@ test -n "$tidy" || {
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"'
-
-tests_done
+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"'
+
+test_done
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index d8f7219..8be77e5 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -5,7 +5,7 @@ test_description='Validate cache'
prepare_tests
-run_test 'verify cache-size=0' '
+test_expect_success 'verify cache-size=0' '
rm -f trash/cache/* &&
sed -i -e "s/cache-size=1021$/cache-size=0/" trash/cgitrc &&
@@ -25,7 +25,7 @@ run_test 'verify cache-size=0' '
test 0 -eq $(ls trash/cache | wc -l)
'
-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 &&
@@ -45,7 +45,7 @@ run_test 'verify cache-size=1' '
test 1 -eq $(ls trash/cache | wc -l)
'
-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 &&
@@ -65,4 +65,4 @@ run_test 'verify cache-size=1021' '
test 13 -eq $(ls trash/cache | wc -l)
'
-tests_done
+test_done
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index b17dabd..d4c4b19 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -5,15 +5,15 @@ test_description='Check content on index page'
prepare_tests
-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'
+test_expect_success 'generate index page' 'cgit_url "" >trash/tmp'
+test_expect_success 'find foo repo' 'grep "foo" trash/tmp'
+test_expect_success 'find foo description' 'grep "\[no description\]" trash/tmp'
+test_expect_success 'find bar repo' 'grep "bar" trash/tmp'
+test_expect_success 'find bar description' 'grep "the bar repo" trash/tmp'
+test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" trash/tmp'
+test_expect_success 'verify foo+bar link' 'grep "/foo+bar/" trash/tmp'
+test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" trash/tmp'
+test_expect_success 'no tree-link' '! grep "foo/tree" trash/tmp'
+test_expect_success '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 e68852c..bfba6a0 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -5,23 +5,23 @@ test_description='Check content on summary page'
prepare_tests
-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' '
+test_expect_success 'generate foo summary' 'cgit_url "foo" >trash/tmp'
+test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp'
+test_expect_success 'find commit 5' 'grep "commit 5" trash/tmp'
+test_expect_success 'find branch master' 'grep "master" trash/tmp'
+test_expect_success 'no tags' '! grep "tags" trash/tmp'
+test_expect_success 'clone-url expanded correctly' '
grep "git://example.org/foo.git" trash/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' '
+test_expect_success 'generate bar summary' 'cgit_url "bar" >trash/tmp'
+test_expect_success 'no commit 45' '! grep "commit 45" trash/tmp'
+test_expect_success 'find commit 46' 'grep "commit 46" trash/tmp'
+test_expect_success 'find commit 50' 'grep "commit 50" trash/tmp'
+test_expect_success 'find branch master' 'grep "master" trash/tmp'
+test_expect_success 'no tags' '! grep "tags" trash/tmp'
+test_expect_success 'clone-url expanded correctly' '
grep "git://example.org/bar.git" trash/tmp
'
-tests_done
+test_done
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index 9b86758..1d6ee05 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -5,22 +5,22 @@ test_description='Check content on log page'
prepare_tests
-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 foo/log' 'cgit_url "foo/log" >trash/tmp'
+test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp'
+test_expect_success 'find commit 5' 'grep "commit 5" trash/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'
+test_expect_success 'generate bar/log' 'cgit_url "bar/log" >trash/tmp'
+test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp'
+test_expect_success 'find commit 50' 'grep "commit 50" trash/tmp'
-run_test 'generate "with%20space/log?qt=grep&q=commit+1"' '
+test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' '
cgit_url "with+space/log&qt=grep&q=commit+1" >trash/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&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" trash/tmp'
+test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" trash/tmp'
+test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" trash/tmp'
+test_expect_success 'no links with space in path' '! grep "href=./with space/" trash/tmp'
+test_expect_success 'no links with space in arg' '! grep "q=commit 1" trash/tmp'
+test_expect_success 'commit 2 is not visible' '! grep "commit 2" trash/tmp'
-tests_done
+test_done
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index c15752c..c0312ff 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -5,30 +5,30 @@ test_description='Check content on tree page'
prepare_tests
-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' 'cgit_url "bar/tree" >trash/tmp'
+test_expect_success 'find file-1' 'grep "file-1" trash/tmp'
+test_expect_success 'find file-50' 'grep "file-50" trash/tmp'
-run_test 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp'
+test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp'
-run_test 'find line 1' '
+test_expect_success 'find line 1' '
grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp
'
-run_test 'no line 2' '
+test_expect_success 'no line 2' '
! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" trash/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" >trash/tmp'
-run_test 'verify a+b link' '
+test_expect_success 'verify a+b link' '
grep "/foo+bar/tree/a+b" trash/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" >trash/tmp'
-run_test 'verify a+b?h=1+2 link' '
+test_expect_success 'verify a+b?h=1+2 link' '
grep "/foo+bar/tree/a+b?h=1%2b2" trash/tmp
'
-tests_done
+test_done
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh
index 7a0bd13..6dee292 100755
--- a/tests/t0105-commit.sh
+++ b/tests/t0105-commit.sh
@@ -5,34 +5,34 @@ test_description='Check content on commit page'
prepare_tests
-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'
+test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >trash/tmp'
+test_expect_success 'find tree link' 'grep "<a href=./foo/tree/.>" trash/tmp'
+test_expect_success 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" trash/tmp'
-run_test 'find commit subject' '
+test_expect_success 'find commit subject' '
grep "<div class=.commit-subject.>commit 5<" trash/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>" trash/tmp'
+test_expect_success 'find diffstat' 'grep "<table summary=.diffstat. class=.diffstat.>" trash/tmp'
-run_test 'find diff summary' '
+test_expect_success 'find diff summary' '
grep "1 files changed, 1 insertions, 0 deletions" trash/tmp
'
-run_test 'get root commit' '
+test_expect_success '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
'
-run_test 'root commit contains diffstat' '
+test_expect_success 'root commit contains diffstat' '
grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" trash/tmp
'
-run_test 'root commit contains diff' '
+test_expect_success 'root commit contains diff' '
grep ">diff --git a/file-1 b/file-1<" trash/tmp &&
grep "<div class=.add.>+1</div>" trash/tmp
'
-tests_done
+test_done
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index ed4fb80..e629f62 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -5,17 +5,17 @@ test_description='Check content on diff page'
prepare_tests
-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'
+test_expect_success 'generate foo/diff' 'cgit_url "foo/diff" >trash/tmp'
+test_expect_success 'find diff header' 'grep "a/file-5 b/file-5" trash/tmp'
+test_expect_success 'find blob link' 'grep "<a href=./foo/tree/file-5?id=" trash/tmp'
+test_expect_success 'find added file' 'grep "new file mode 100644" trash/tmp'
-run_test 'find hunk header' '
+test_expect_success 'find hunk header' '
grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" trash/tmp
'
-run_test 'find added line' '
+test_expect_success 'find added line' '
grep "<div class=.add.>+5</div>" trash/tmp
'
-tests_done
+test_done
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 7eeb77a..35b6663 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -5,11 +5,11 @@ test_description='Verify snapshot'
prepare_tests
-run_test 'get foo/snapshot/master.tar.gz' '
+test_expect_success 'get foo/snapshot/master.tar.gz' '
cgit_url "foo/snapshot/master.tar.gz" >trash/tmp
'
-run_test 'check html headers' '
+test_expect_success 'check html headers' '
head -n 1 trash/tmp |
grep "Content-Type: application/x-gzip" &&
@@ -17,34 +17,34 @@ run_test 'check html headers' '
grep "Content-Disposition: inline; filename=.master.tar.gz."
'
-run_test 'strip off the header lines' '
+test_expect_success 'strip off the header lines' '
tail -n +6 trash/tmp > trash/master.tar.gz
'
-run_test 'verify gzip format' '
+test_expect_success 'verify gzip format' '
gunzip --test trash/master.tar.gz
'
-run_test 'untar' '
+test_expect_success 'untar' '
rm -rf trash/master &&
tar -xf trash/master.tar.gz -C trash
'
-run_test 'count files' '
+test_expect_success 'count files' '
c=$(ls -1 trash/master/ | wc -l) &&
test $c = 5
'
-run_test 'verify untarred file-5' '
+test_expect_success 'verify untarred file-5' '
grep "^5$" trash/master/file-5 &&
test $(cat trash/master/file-5 | wc -l) = 1
'
-run_test 'get foo/snapshot/master.zip' '
+test_expect_success 'get foo/snapshot/master.zip' '
cgit_url "foo/snapshot/master.zip" >trash/tmp
'
-run_test 'check HTML headers (zip)' '
+test_expect_success 'check HTML headers (zip)' '
head -n 1 trash/tmp |
grep "Content-Type: application/x-zip" &&
@@ -52,27 +52,27 @@ run_test 'check HTML headers (zip)' '
grep "Content-Disposition: inline; filename=.master.zip."
'
-run_test 'strip off the header lines (zip)' '
+test_expect_success 'strip off the header lines (zip)' '
tail -n +6 trash/tmp >trash/master.zip
'
-run_test 'verify zip format' '
+test_expect_success 'verify zip format' '
unzip -t trash/master.zip
'
-run_test 'unzip' '
+test_expect_success 'unzip' '
rm -rf trash/master &&
unzip trash/master.zip -d trash
'
-run_test 'count files (zip)' '
+test_expect_success 'count files (zip)' '
c=$(ls -1 trash/master/ | wc -l) &&
test $c = 5
'
-run_test 'verify unzipped file-5' '
+test_expect_success 'verify unzipped file-5' '
grep "^5$" trash/master/file-5 &&
test $(cat trash/master/file-5 | wc -l) = 1
'
-tests_done
+test_done
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index 580fd43..9296f6a 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -5,36 +5,36 @@ test_description='Check content on patch page'
prepare_tests
-run_test 'generate foo/patch' '
+test_expect_success 'generate foo/patch' '
cgit_query "url=foo/patch" >trash/tmp
'
-run_test 'find `From:` line' '
+test_expect_success 'find `From:` line' '
grep "^From: " trash/tmp
'
-run_test 'find `Date:` line' '
+test_expect_success 'find `Date:` line' '
grep "^Date: " trash/tmp
'
-run_test 'find `Subject:` line' '
+test_expect_success 'find `Subject:` line' '
grep "^Subject: commit 5" trash/tmp
'
-run_test 'find `cgit` signature' '
+test_expect_success 'find `cgit` signature' '
tail -1 trash/tmp | grep "^cgit"
'
-run_test 'find initial commit' '
+test_expect_success 'find initial commit' '
root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1)
'
-run_test 'generate patch for initial commit' '
+test_expect_success 'generate patch for initial commit' '
cgit_query "url=foo/patch&id=$root" >trash/tmp
'
-run_test 'find `cgit` signature' '
+test_expect_success 'find `cgit` signature' '
tail -1 trash/tmp | grep "^cgit"
'
-tests_done
+test_done
--
1.8.2.694.ga76e9c3.dirty
More information about the CGit
mailing list