Diffstat (limited to 'tests')
| -rw-r--r-- | tests/.gitignore | 2 | ||||
| -rw-r--r-- | tests/Makefile | 13 | ||||
| -rwxr-xr-x | tests/setup.sh | 108 | ||||
| -rwxr-xr-x | tests/t0010-validate-html.sh | 31 | ||||
| -rwxr-xr-x | tests/t0101-index.sh | 13 | ||||
| -rwxr-xr-x | tests/t0102-summary.sh | 20 | ||||
| -rwxr-xr-x | tests/t0103-log.sh | 15 | ||||
| -rwxr-xr-x | tests/t0104-tree.sh | 21 | ||||
| -rwxr-xr-x | tests/t0105-commit.sh | 22 | ||||
| -rwxr-xr-x | tests/t0106-diff.sh | 20 | ||||
| -rwxr-xr-x | tests/t0107-snapshot.sh | 36 |
11 files changed, 0 insertions, 301 deletions
diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index c1c1c0b..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -trash -test-output.log diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 697e5a1..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - - -T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) - -all: $(T) - -$(T): - @$@ - -clean: - $(RM) -rf trash - -.PHONY: $(T) clean diff --git a/tests/setup.sh b/tests/setup.sh deleted file mode 100755 index 51d5a75..0000000 --- a/tests/setup.sh +++ /dev/null @@ -1,108 +0,0 @@ -# This file should be sourced by all test-scripts -# -# Main functions: -# prepare_tests(description) - setup for testing, i.e. create repos+config -# run_test(description, script) - run one test, i.e. eval script -# -# Helper functions -# cgit_query(querystring) - call cgit with the specified querystring -# cgit_url(url) - call cgit with the specified virtual url -# -# Example script: -# -# . setup.sh -# prepare_tests "html validation" -# run_test 'repo index' 'cgit_url "/" | tidy -e' -# run_test 'repo summary' 'cgit_url "/foo" | tidy -e' - - -mkrepo() { - name=$1 - count=$2 - dir=$PWD - test -d $name && return - printf "Creating testrepo %s\n" $name - mkdir -p $name - cd $name - git init - for ((n=1; n<=count; n++)) - do - echo $n >file-$n - git add file-$n - git commit -m "commit $n" - done - cd $dir -} - -setup_repos() -{ - rm -rf trash/cache - mkdir -p trash/cache - mkrepo trash/repos/foo 5 >/dev/null - mkrepo trash/repos/bar 50 >/dev/null - cat >trash/cgitrc <<EOF -virtual-root=/ -cache-root=$PWD/trash/cache - -nocache=0 -snapshots=tar.gz tar.bz zip -enable-log-filecount=1 -enable-log-linecount=1 -summary-log=5 -summary-branches=5 -summary-tags=5 - -repo.url=foo -repo.path=$PWD/trash/repos/foo/.git -repo.desc=the foo repo - -repo.url=bar -repo.path=$PWD/trash/repos/bar/.git -repo.desc=the bar repo -EOF -} - -prepare_tests() -{ - setup_repos - test_count=0 - test_failed=0 - echo "$@" "($0)" -} - -tests_done() -{ - printf "\n" - if test $test_failed -gt 0 - then - printf "[%s of %s tests failed]\n" $test_failed $test_count - false - fi -} - -run_test() -{ - desc=$1 - script=$2 - ((test_count++)) - eval "$2" >test-output.log - res=$? - if test $res = 0 - then - printf " %s: ok - %s\n" $test_count "$desc" - else - ((test_failed++)) - printf " %s: fail - %s\n" $test_count "$desc" - fi -} - -cgit_query() -{ - CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="$1" "$PWD/../cgit" -} - -cgit_url() -{ - CGIT_CONFIG="$PWD/trash/cgitrc" QUERY_STRING="url=$1" "$PWD/../cgit" -} - diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh deleted file mode 100755 index 907a415..0000000 --- a/tests/t0010-validate-html.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -. ./setup.sh - - -test_url() -{ - tidy_opt="-eq" - test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" - cgit_url "$1" | sed -e "1,4d" >trash/tidy-$test_count - tidy $tidy_opt trash/tidy-$test_count - rc=$? - if test $rc = 2 - then - false - else - : - fi -} - -prepare_tests 'Validate html with tidy' - -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 diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh deleted file mode 100755 index 12ed00c..0000000 --- a/tests/t0101-index.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Check content on index page" - -run_test 'generate index page' 'cgit_url "" >trash/tmp' -run_test 'find foo repo' 'grep -e "foo" trash/tmp' -run_test 'find bar repo' 'grep -e "bar" trash/tmp' -run_test 'no tree-link' 'grep -ve "foo/tree" trash/tmp' -run_test 'no log-link' 'grep -ve "foo/log" trash/tmp' - -tests_done diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh deleted file mode 100755 index 7edd675..0000000 --- a/tests/t0102-summary.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -. ./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 -e "commit 1" trash/tmp' -run_test 'find commit 5' 'grep -e "commit 5" trash/tmp' -run_test 'find branch master' 'grep -e "master" trash/tmp' -run_test 'no tags' 'grep -ve "tags" trash/tmp' - -run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp' -run_test 'no commit 45' 'grep -ve "commit 45" trash/tmp' -run_test 'find commit 46' 'grep -e "commit 46" trash/tmp' -run_test 'find commit 50' 'grep -e "commit 50" trash/tmp' -run_test 'find branch master' 'grep -e "master" trash/tmp' -run_test 'no tags' 'grep -ve "tags" trash/tmp' - -tests_done diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh deleted file mode 100755 index b08cd29..0000000 --- a/tests/t0103-log.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Check content on log page" - -run_test 'generate foo/log' 'cgit_url "foo/log" >trash/tmp' -run_test 'find commit 1' 'grep -e "commit 1" trash/tmp' -run_test 'find commit 5' 'grep -e "commit 5" trash/tmp' - -run_test 'generate bar/log' 'cgit_url "bar/log" >trash/tmp' -run_test 'find commit 1' 'grep -e "commit 1" trash/tmp' -run_test 'find commit 50' 'grep -e "commit 50" trash/tmp' - -tests_done diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh deleted file mode 100755 index 2516c72..0000000 --- a/tests/t0104-tree.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Check content on tree page" - -run_test 'generate bar/tree' 'cgit_url "bar/tree" >trash/tmp' -run_test 'find file-1' 'grep -e "file-1" trash/tmp' -run_test 'find file-50' 'grep -e "file-50" trash/tmp' - -run_test 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp' - -run_test 'find line 1' ' - grep -e "<a id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp -' - -run_test 'no line 2' ' - grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp -' - -tests_done diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh deleted file mode 100755 index aa2bf33..0000000 --- a/tests/t0105-commit.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Check content on commit page" - -run_test 'generate foo/commit' 'cgit_url "foo/commit" >trash/tmp' -run_test 'find tree link' 'grep -e "<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 -e "<div class=.commit-subject.>commit 5</div>" trash/tmp -' - -run_test 'find commit msg' 'grep -e "<div class=.commit-msg.></div>" trash/tmp' -run_test 'find diffstat' 'grep -e "<table summary=.diffstat. class=.diffstat.>" trash/tmp' - -run_test 'find diff summary' ' - grep -e "1 files changed, 1 insertions, 0 deletions" trash/tmp -' - -tests_done diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh deleted file mode 100755 index e140bcc..0000000 --- a/tests/t0106-diff.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Check content on diff page" - -run_test 'generate foo/diff' 'cgit_url "foo/diff" >trash/tmp' -run_test 'find diff header' 'grep -e "a/file-5 b/file-5" trash/tmp' -run_test 'find blob link' 'grep -e "<a href=./foo/tree/file-5?id=" trash/tmp' -run_test 'find added file' 'grep -e "new file mode 100644" trash/tmp' - -run_test 'find hunk header' ' - grep -e "<div class=.hunk.>@@ -0,0 +1 @@</div>" trash/tmp -' - -run_test 'find added line' ' - grep -e "<div class=.add.>+5</div>" trash/tmp -' - -tests_done diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh deleted file mode 100755 index 8e90e10..0000000 --- a/tests/t0107-snapshot.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -. ./setup.sh - -prepare_tests "Verify snapshot" - -run_test 'get foo/snapshot/test.tar.gz' ' - cgit_url "foo/snapshot/test.tar.gz" >trash/tmp -' - -run_test 'check html headers' ' - head -n 1 trash/tmp | - grep -e "Content-Type: application/x-tar" && - - head -n 2 trash/tmp | - grep -e "Content-Disposition: inline; filename=.test.tar.gz." -' - -run_test 'strip off the header lines' ' - tail -n +6 trash/tmp > trash/test.tar.gz -' - -run_test 'verify gzip format' 'gunzip --test trash/test.tar.gz' -run_test 'untar' 'tar -xf trash/test.tar.gz -C trash' - -run_test 'count files' ' - c=$(ls -1 trash/foo/ | wc -l) && - test $c = 5 -' - -run_test 'verify untarred file-5' ' - grep -e "^5$" trash/foo/file-5 && - test $(cat trash/foo/file-5 | wc -l) = 1 -' - -tests_done |