* [PATCH 01/12] tests: use Git test functions directly
2013-04-08 19:12 [PATCH 00/12] Test improvements john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 02/12] tests: don't let Git's test-lib create a repository john
` (10 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 02/12] tests: don't let Git's test-lib create a repository
2013-04-08 19:12 [PATCH 00/12] Test improvements john
2013-04-08 19:12 ` [PATCH 01/12] tests: use Git test functions directly john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 03/12] tests: remove prepare_tests john
` (9 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
We create our own repository structure for all CGit tests, so letting
Git's test-lib.sh create one as well just causes an unnecessary call to
git-init.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/setup.sh b/tests/setup.sh
index 774056b..1100449 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -16,6 +16,7 @@
# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
: ${TEST_DIRECTORY=$(pwd)/../git/t}
+TEST_NO_CREATE_REPO=YesPlease
. "$TEST_DIRECTORY"/test-lib.sh
mkrepo() {
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 03/12] tests: remove prepare_tests
2013-04-08 19:12 [PATCH 00/12] Test improvements john
2013-04-08 19:12 ` [PATCH 01/12] tests: use Git test functions directly john
2013-04-08 19:12 ` [PATCH 02/12] tests: don't let Git's test-lib create a repository john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 04/12] t0001: don't setup test repositories john
` (8 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
Instead, setup the test repositories automatically. Provide a variable
that can be used by tests to override this behaviour if they want.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 7 ++-----
tests/t0001-validate-git-versions.sh | 2 --
tests/t0010-validate-html.sh | 2 --
tests/t0020-validate-cache.sh | 2 --
tests/t0101-index.sh | 2 --
tests/t0102-summary.sh | 2 --
tests/t0103-log.sh | 2 --
tests/t0104-tree.sh | 2 --
tests/t0105-commit.sh | 2 --
tests/t0106-diff.sh | 2 --
tests/t0107-snapshot.sh | 2 --
tests/t0108-patch.sh | 2 --
12 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/tests/setup.sh b/tests/setup.sh
index 1100449..962d96b 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -87,11 +87,6 @@ repo.desc=spaced repo
EOF
}
-prepare_tests()
-{
- setup_repos
-}
-
cgit_query()
{
CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="$1" "$PWD/../../cgit"
@@ -101,3 +96,5 @@ cgit_url()
{
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 02cb35a..61c2062 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -3,8 +3,6 @@
test_description='Check Git version is correct'
. ./setup.sh
-prepare_tests
-
test_expect_success 'extract Git version from Makefile' '
sed -n -e "/^GIT_VER[ ]*=/ {
s/^GIT_VER[ ]*=[ ]*//
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index 9cc0fdd..36d2ab6 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -22,8 +22,6 @@ test_url()
fi
}
-prepare_tests
-
tidy=`which tidy 2>/dev/null`
test -n "$tidy" || {
skip_all='Skipping html validation tests: tidy not found'
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index 8be77e5..b6a12c7 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -3,8 +3,6 @@
test_description='Validate cache'
. ./setup.sh
-prepare_tests
-
test_expect_success 'verify cache-size=0' '
rm -f trash/cache/* &&
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index d4c4b19..69c92d1 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -3,8 +3,6 @@
test_description='Check content on index page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index bfba6a0..470f89e 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -3,8 +3,6 @@
test_description='Check content on summary page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index 1d6ee05..ec873bc 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -3,8 +3,6 @@
test_description='Check content on log page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index c0312ff..ecf96e6 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -3,8 +3,6 @@
test_description='Check content on tree page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh
index 6dee292..ae6bd94 100755
--- a/tests/t0105-commit.sh
+++ b/tests/t0105-commit.sh
@@ -3,8 +3,6 @@
test_description='Check content on commit page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index e629f62..427ad29 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -3,8 +3,6 @@
test_description='Check content on diff page'
. ./setup.sh
-prepare_tests
-
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'
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 35b6663..271cdb4 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -3,8 +3,6 @@
test_description='Verify snapshot'
. ./setup.sh
-prepare_tests
-
test_expect_success 'get foo/snapshot/master.tar.gz' '
cgit_url "foo/snapshot/master.tar.gz" >trash/tmp
'
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index 9296f6a..8bf6914 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -3,8 +3,6 @@
test_description='Check content on patch page'
. ./setup.sh
-prepare_tests
-
test_expect_success 'generate foo/patch' '
cgit_query "url=foo/patch" >trash/tmp
'
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 04/12] t0001: don't setup test repositories
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (2 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 03/12] tests: remove prepare_tests john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 05/12] tests/.gitignore: update for using Git's test infrastructure john
` (7 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
This test doesn't use the test repositories, so it doesn't need them
created.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/t0001-validate-git-versions.sh | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh
index 61c2062..9591d3e 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -1,19 +1,20 @@
#!/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' '
sed -n -e "/^GIT_VER[ ]*=/ {
s/^GIT_VER[ ]*=[ ]*//
p
- }" ../../Makefile >trash/makefile_version
+ }" ../../Makefile >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[ ]*=[ ]*//" >trash/git_version &&
- diff -u trash/git_version trash/makefile_version
+ sed -e "s/GIT_VERSION[ ]*=[ ]*//" >git_version &&
+ diff -u git_version makefile_version
'
test_expect_success 'test submodule version matches Makefile' '
@@ -27,8 +28,8 @@ test_expect_success 'test submodule version matches Makefile' '
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 &&
+ diff -u sm_version makefile_version
fi
'
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 05/12] tests/.gitignore: update for using Git's test infrastructure
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (3 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 04/12] t0001: don't setup test repositories john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 06/12] tests: remove "trash" directory john
` (6 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/.gitignore | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/.gitignore b/tests/.gitignore
index c1c1c0b..3fd2e96 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,2 +1,2 @@
-trash
-test-output.log
+trash\ directory.t*
+test-results
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 06/12] tests: remove "trash" directory
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (4 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 05/12] tests/.gitignore: update for using Git's test infrastructure john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 07/12] tests: put cgit onto $PATH john
` (5 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
Now that we're using Git's test framework, it generates a suitable trash
directory for us to use, so we don't need to create a "trash"
subdirectory.
This patch was generated with "sed -i -e 's!trash/!!g' tests/*.sh" with
the t0107-snapshot.sh tests fixed to avoid passing "-C trash" to tar or
"-d trash" to unzip.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 28 ++++++++++++++--------------
tests/t0010-validate-html.sh | 6 +++---
tests/t0020-validate-cache.sh | 18 +++++++++---------
tests/t0101-index.sh | 20 ++++++++++----------
tests/t0102-summary.sh | 26 +++++++++++++-------------
tests/t0103-log.sh | 26 +++++++++++++-------------
tests/t0104-tree.sh | 20 ++++++++++----------
tests/t0105-commit.sh | 26 +++++++++++++-------------
tests/t0106-diff.sh | 12 ++++++------
tests/t0107-snapshot.sh | 40 ++++++++++++++++++++--------------------
tests/t0108-patch.sh | 16 ++++++++--------
11 files changed, 119 insertions(+), 119 deletions(-)
diff --git a/tests/setup.sh b/tests/setup.sh
index 962d96b..f4bdafd 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -48,15 +48,15 @@ mkrepo() {
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
@@ -68,33 +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
}
cgit_query()
{
- CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="$1" "$PWD/../../cgit"
+ CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="$1" "$PWD/../../cgit"
}
cgit_url()
{
- CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="url=$1" "$PWD/../../cgit"
+ CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="url=$1" "$PWD/../../cgit"
}
test -z "$CGIT_TEST_NO_CREATE_REPOS" && setup_repos
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index 36d2ab6..d4b50ad 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -8,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
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index b6a12c7..135b24d 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -5,8 +5,8 @@ test_description='Validate cache'
test_expect_success '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" &&
@@ -20,13 +20,13 @@ test_expect_success 'verify cache-size=0' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 0 -eq $(ls trash/cache | wc -l)
+ test 0 -eq $(ls cache | wc -l)
'
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" &&
@@ -40,13 +40,13 @@ test_expect_success 'verify cache-size=1' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 1 -eq $(ls trash/cache | wc -l)
+ test 1 -eq $(ls cache | wc -l)
'
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" &&
@@ -60,7 +60,7 @@ test_expect_success 'verify cache-size=1021' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 13 -eq $(ls trash/cache | wc -l)
+ test 13 -eq $(ls cache | wc -l)
'
test_done
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index 69c92d1..82ef9b0 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -3,15 +3,15 @@
test_description='Check content on index page'
. ./setup.sh
-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'
+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'
test_done
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index 470f89e..b8864cb 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -3,23 +3,23 @@
test_description='Check content on summary page'
. ./setup.sh
-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 '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" trash/tmp
+ grep "git://example.org/foo.git" tmp
'
-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 '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" trash/tmp
+ grep "git://example.org/bar.git" tmp
'
test_done
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index ec873bc..bdf1435 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -3,22 +3,22 @@
test_description='Check content on log page'
. ./setup.sh
-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'
+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'
-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'
+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'
test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' '
- cgit_url "with+space/log&qt=grep&q=commit+1" >trash/tmp
+ cgit_url "with+space/log&qt=grep&q=commit+1" >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'
+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&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'
test_done
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index ecf96e6..100b026 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -3,30 +3,30 @@
test_description='Check content on tree page'
. ./setup.sh
-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'
+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'
-test_expect_success '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" >tmp'
test_expect_success 'find line 1' '
- grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp
+ grep "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" tmp
'
test_expect_success 'no line 2' '
- ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
+ ! grep "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" tmp
'
-test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'
+test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp'
test_expect_success 'verify a+b link' '
- grep "/foo+bar/tree/a+b" trash/tmp
+ grep "/foo+bar/tree/a+b" tmp
'
-test_expect_success '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'
test_expect_success 'verify a+b?h=1+2 link' '
- grep "/foo+bar/tree/a+b?h=1%2b2" trash/tmp
+ grep "/foo+bar/tree/a+b?h=1%2b2" tmp
'
test_done
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh
index ae6bd94..9cdf55c 100755
--- a/tests/t0105-commit.sh
+++ b/tests/t0105-commit.sh
@@ -3,34 +3,34 @@
test_description='Check content on commit page'
. ./setup.sh
-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'
+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'
test_expect_success 'find commit subject' '
- grep "<div class=.commit-subject.>commit 5<" trash/tmp
+ grep "<div class=.commit-subject.>commit 5<" 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'
+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'
test_expect_success 'find diff summary' '
- grep "1 files changed, 1 insertions, 0 deletions" trash/tmp
+ grep "1 files changed, 1 insertions, 0 deletions" tmp
'
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
+ root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) &&
+ cgit_url "foo/commit&id=$root" >tmp &&
+ grep "</html>" tmp
'
test_expect_success 'root commit contains diffstat' '
- grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" trash/tmp
+ grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" tmp
'
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
+ grep ">diff --git a/file-1 b/file-1<" tmp &&
+ grep "<div class=.add.>+1</div>" tmp
'
test_done
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
index 427ad29..82b645e 100755
--- a/tests/t0106-diff.sh
+++ b/tests/t0106-diff.sh
@@ -3,17 +3,17 @@
test_description='Check content on diff page'
. ./setup.sh
-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'
+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'
test_expect_success 'find hunk header' '
- grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" trash/tmp
+ grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" tmp
'
test_expect_success 'find added line' '
- grep "<div class=.add.>+5</div>" trash/tmp
+ grep "<div class=.add.>+5</div>" tmp
'
test_done
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index 271cdb4..e244968 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -4,73 +4,73 @@ test_description='Verify snapshot'
. ./setup.sh
test_expect_success 'get foo/snapshot/master.tar.gz' '
- cgit_url "foo/snapshot/master.tar.gz" >trash/tmp
+ cgit_url "foo/snapshot/master.tar.gz" >tmp
'
test_expect_success 'check html headers' '
- head -n 1 trash/tmp |
+ 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."
'
test_expect_success 'strip off the header lines' '
- tail -n +6 trash/tmp > trash/master.tar.gz
+ tail -n +6 tmp > master.tar.gz
'
test_expect_success 'verify gzip format' '
- gunzip --test trash/master.tar.gz
+ gunzip --test master.tar.gz
'
test_expect_success 'untar' '
- rm -rf trash/master &&
- tar -xf trash/master.tar.gz -C trash
+ rm -rf master &&
+ tar -xf master.tar.gz
'
test_expect_success 'count files' '
- c=$(ls -1 trash/master/ | wc -l) &&
+ c=$(ls -1 master/ | wc -l) &&
test $c = 5
'
test_expect_success 'verify untarred file-5' '
- grep "^5$" trash/master/file-5 &&
- test $(cat trash/master/file-5 | wc -l) = 1
+ grep "^5$" master/file-5 &&
+ test $(cat master/file-5 | wc -l) = 1
'
test_expect_success 'get foo/snapshot/master.zip' '
- cgit_url "foo/snapshot/master.zip" >trash/tmp
+ cgit_url "foo/snapshot/master.zip" >tmp
'
test_expect_success 'check HTML headers (zip)' '
- head -n 1 trash/tmp |
+ 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."
'
test_expect_success 'strip off the header lines (zip)' '
- tail -n +6 trash/tmp >trash/master.zip
+ tail -n +6 tmp >master.zip
'
test_expect_success 'verify zip format' '
- unzip -t trash/master.zip
+ unzip -t master.zip
'
test_expect_success 'unzip' '
- rm -rf trash/master &&
- unzip trash/master.zip -d trash
+ rm -rf master &&
+ unzip master.zip
'
test_expect_success 'count files (zip)' '
- c=$(ls -1 trash/master/ | wc -l) &&
+ c=$(ls -1 master/ | wc -l) &&
test $c = 5
'
test_expect_success 'verify unzipped file-5' '
- grep "^5$" trash/master/file-5 &&
- test $(cat trash/master/file-5 | wc -l) = 1
+ grep "^5$" master/file-5 &&
+ test $(cat master/file-5 | wc -l) = 1
'
test_done
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index 8bf6914..3b5bae4 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -4,35 +4,35 @@ test_description='Check content on patch page'
. ./setup.sh
test_expect_success 'generate foo/patch' '
- cgit_query "url=foo/patch" >trash/tmp
+ cgit_query "url=foo/patch" >tmp
'
test_expect_success 'find `From:` line' '
- grep "^From: " trash/tmp
+ grep "^From: " tmp
'
test_expect_success 'find `Date:` line' '
- grep "^Date: " trash/tmp
+ grep "^Date: " tmp
'
test_expect_success 'find `Subject:` line' '
- grep "^Subject: commit 5" trash/tmp
+ grep "^Subject: commit 5" tmp
'
test_expect_success 'find `cgit` signature' '
- tail -1 trash/tmp | grep "^cgit"
+ tail -1 tmp | grep "^cgit"
'
test_expect_success 'find initial commit' '
- root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1)
+ root=$(git --git-dir="$PWD/repos/foo/.git" rev-list HEAD | tail -1)
'
test_expect_success 'generate patch for initial commit' '
- cgit_query "url=foo/patch&id=$root" >trash/tmp
+ cgit_query "url=foo/patch&id=$root" >tmp
'
test_expect_success 'find `cgit` signature' '
- tail -1 trash/tmp | grep "^cgit"
+ tail -1 tmp | grep "^cgit"
'
test_done
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 07/12] tests: put cgit onto $PATH
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (5 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 06/12] tests: remove "trash" directory john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 08/12] .gitignore: tighten cgit ignore expression john
` (4 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
This will allow us to override the path with wrappers to provide
additional functionality, such as for Valgrind.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/setup.sh b/tests/setup.sh
index f4bdafd..81594cf 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -19,6 +19,9 @@
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
@@ -89,12 +92,12 @@ EOF
cgit_query()
{
- CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="$1" "$PWD/../../cgit"
+ CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="$1" cgit
}
cgit_url()
{
- CGIT_CONFIG="$PWD/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
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 08/12] .gitignore: tighten cgit ignore expression
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (6 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 07/12] tests: put cgit onto $PATH john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 09/12] tests: add Valgrind support john
` (3 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
This will allow wrappers added under tests/ to be added to version
control.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 8011b39..661df34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
# Files I don't care to see in git-status/commit
-cgit
+/cgit
cgit.conf
CGIT-CFLAGS
VERSION
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 09/12] tests: add Valgrind support
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (7 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 08/12] .gitignore: tighten cgit ignore expression john
@ 2013-04-08 19:12 ` john
2013-04-08 19:23 ` Jason
2013-04-08 19:12 ` [PATCH 10/12] t0001: use test_cmp instead of 'diff -u' john
` (2 subsequent siblings)
11 siblings, 1 reply; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
Now running tests with the "--valgrind" option will run cgit under
Valgrind instead of all Git commands.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 37 ++++++++++++++++++++++++++++++++++++-
tests/valgrind/bin/cgit | 12 ++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)
create mode 100755 tests/valgrind/bin/cgit
diff --git a/tests/setup.sh b/tests/setup.sh
index 81594cf..5977390 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -15,12 +15,47 @@
# run_test 'repo index' 'cgit_url "/" | tidy -e'
# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
+# We don't want to run Git commands through Valgrind, so we filter out the
+# --valgrind option here and handle it ourselves. We copy the arguments
+# assuming that none contain a newline, although other whitespace is
+# preserved.
+LF='
+'
+test_argv=
+
+while test $# != 0
+do
+ case "$1" in
+ --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
+ cgit_valgrind=t
+ test_argv="$test_argv${LF}--verbose"
+ ;;
+ *)
+ test_argv="$test_argv$LF$1"
+ ;;
+ esac
+ shift
+done
+
+OLDIFS=$IFS
+IFS=$LF
+set -- $test_argv
+IFS=$OLDIFS
+
: ${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"
+if test -n "$cgit_valgrind"
+then
+ GIT_VALGRIND="$TEST_DIRECTORY/valgrind"
+ CGIT_VALGRIND=$(cd ../valgrind && pwd)
+ PATH="$CGIT_VALGRIND/bin:$PATH"
+ export GIT_VALGRIND CGIT_VALGRIND
+else
+ PATH="$(pwd)/../..:$PATH"
+fi
mkrepo() {
name=$1
diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit
new file mode 100755
index 0000000..dcdfbe5
--- /dev/null
+++ b/tests/valgrind/bin/cgit
@@ -0,0 +1,12 @@
+#!/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.
+exec valgrind -q --error-exitcode=126 \
+ --suppressions="$GIT_VALGRIND/default.supp" \
+ --gen-suppressions=all \
+ --leak-check=no \
+ --track-origins=yes \
+ --log-fd=4 \
+ --input-fd=4 \
+ "$CGIT_VALGRIND/../../cgit" "$@"
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 10/12] t0001: use test_cmp instead of 'diff -u'
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (8 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 09/12] tests: add Valgrind support john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 11/12] tests: use test_line_count where appropriate john
2013-04-08 19:12 ` [PATCH 12/12] tests: use test_create_repo instead of "git init" john
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/t0001-validate-git-versions.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh
index 9591d3e..754046e 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -14,7 +14,7 @@ test_expect_success 'extract Git version from Makefile' '
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 &&
- diff -u git_version makefile_version
+ test_cmp git_version makefile_version
'
test_expect_success 'test submodule version matches Makefile' '
@@ -29,7 +29,7 @@ test_expect_success 'test submodule version matches Makefile' '
cd git &&
git describe --match "v[0-9]*" $sm_sha1
) | sed -e "s/^v//" >sm_version &&
- diff -u sm_version makefile_version
+ test_cmp sm_version makefile_version
fi
'
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 11/12] tests: use test_line_count where appropriate
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (9 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 10/12] t0001: use test_cmp instead of 'diff -u' john
@ 2013-04-08 19:12 ` john
2013-04-08 19:12 ` [PATCH 12/12] tests: use test_create_repo instead of "git init" john
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
This gets us better output when the line count is incorrect, which will
help debugging test failures.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/t0020-validate-cache.sh | 9 ++++++---
tests/t0107-snapshot.sh | 14 +++++++-------
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh
index 135b24d..1910b47 100755
--- a/tests/t0020-validate-cache.sh
+++ b/tests/t0020-validate-cache.sh
@@ -20,7 +20,8 @@ test_expect_success 'verify cache-size=0' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 0 -eq $(ls cache | wc -l)
+ ls cache >output &&
+ test_line_count = 0 output
'
test_expect_success 'verify cache-size=1' '
@@ -40,7 +41,8 @@ test_expect_success 'verify cache-size=1' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 1 -eq $(ls cache | wc -l)
+ ls cache >output &&
+ test_line_count = 1 output
'
test_expect_success 'verify cache-size=1021' '
@@ -60,7 +62,8 @@ test_expect_success 'verify cache-size=1021' '
cgit_url "bar/log" &&
cgit_url "bar/diff" &&
cgit_url "bar/patch" &&
- test 13 -eq $(ls cache | wc -l)
+ ls cache >output &&
+ test_line_count = 13 output
'
test_done
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh
index e244968..4fbe45e 100755
--- a/tests/t0107-snapshot.sh
+++ b/tests/t0107-snapshot.sh
@@ -29,13 +29,13 @@ test_expect_success 'untar' '
'
test_expect_success 'count files' '
- c=$(ls -1 master/ | wc -l) &&
- test $c = 5
+ ls master/ >output &&
+ test_line_count = 5 output
'
test_expect_success 'verify untarred file-5' '
grep "^5$" master/file-5 &&
- test $(cat master/file-5 | wc -l) = 1
+ test_line_count = 1 master/file-5
'
test_expect_success 'get foo/snapshot/master.zip' '
@@ -64,13 +64,13 @@ test_expect_success 'unzip' '
'
test_expect_success 'count files (zip)' '
- c=$(ls -1 master/ | wc -l) &&
- test $c = 5
+ ls master/ >output &&
+ test_line_count = 5 output
'
test_expect_success 'verify unzipped file-5' '
- grep "^5$" master/file-5 &&
- test $(cat master/file-5 | wc -l) = 1
+ grep "^5$" master/file-5 &&
+ test_line_count = 1 master/file-5
'
test_done
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 12/12] tests: use test_create_repo instead of "git init"
2013-04-08 19:12 [PATCH 00/12] Test improvements john
` (10 preceding siblings ...)
2013-04-08 19:12 ` [PATCH 11/12] tests: use test_line_count where appropriate john
@ 2013-04-08 19:12 ` john
11 siblings, 0 replies; 14+ messages in thread
From: john @ 2013-04-08 19:12 UTC (permalink / raw)
This gets us a more consistent initial repository state with a fixed
template and no hooks.
Also change the setup code to use a subshell instead of the "cd there;
...; cd back" anti-pattern.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
tests/setup.sh | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/tests/setup.sh b/tests/setup.sh
index 5977390..f5a788e 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -60,28 +60,25 @@ fi
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()
--
1.8.2.694.ga76e9c3.dirty
^ permalink raw reply [flat|nested] 14+ messages in thread