Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Fail where a test fixture breaks
mkrepo had no && chain, so a failed add or commit went unnoticed and
every mkrepo call in the tests passed on a broken repository. The
shared fixtures were built the same way. They are still built when
setup.sh is sourced, so --run can pick out any test, but a failure now
stops the run where it broke.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/setup.sh | 53 |
1 file changed, 29 insertions, 24 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index c035606..563412e 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -113,25 +113,24 @@ unset cgit_version cgit_flags # argument asks for a variant, either testplus for a file and a branch whose # names have to be escaped in a URL, or commit-graph for a written commit graph. mkrepo() { - repo=$1 - commits=$2 - variant=$3 - test_create_repo "$repo" + mkrepo_commits=$2 + mkrepo_variant=$3 + test_create_repo "$1" && ( - cd "$repo" - n=1 - while test $n -le $commits + cd "$1" && + n=1 && + while test $n -le $mkrepo_commits do - echo $n >file-$n - git add file-$n - git commit -m "commit $n" - n=$((n + 1)) - done - case "$variant" in + echo $n >file-$n && + git add file-$n && + git commit -m "commit $n" && + n=$((n + 1)) || exit 1 + done && + case "$mkrepo_variant" in testplus) - echo "hello" >a+b - git add a+b - git commit -m "add a+b" + echo "hello" >a+b && + git add a+b && + git commit -m "add a+b" && git branch "1+2" ;; commit-graph) @@ -142,13 +141,13 @@ mkrepo() { } setup_repos() { - mkdir cache - mkrepo repos/foo 5 >/dev/null - mkrepo repos/bar 50 commit-graph >/dev/null - mkrepo repos/foo+bar 10 testplus >/dev/null - mkrepo "repos/with space" 2 >/dev/null - mkrepo repos/filter 5 testplus >/dev/null - cat >cgitrc <<EOF + mkdir cache && + mkrepo repos/foo 5 >/dev/null && + mkrepo repos/bar 50 commit-graph >/dev/null && + mkrepo repos/foo+bar 10 testplus >/dev/null && + mkrepo "repos/with space" 2 >/dev/null && + mkrepo repos/filter 5 testplus >/dev/null && + cat >cgitrc <<EOF && virtual-root=/ cache-root=$PWD/cache @@ -270,4 +269,10 @@ strip_headers() { cat } -test -z "$CGIT_TEST_NO_CREATE_REPOS" && setup_repos +# The fixtures are built here rather than in a test so that --run can still +# pick out any test, and a fixture that cannot be built stops the run where +# it broke rather than failing every test after it. +if test -z "$CGIT_TEST_NO_CREATE_REPOS" +then + setup_repos || BAIL_OUT "the shared repositories could not be built" +fi |
