summaryrefslogtreecommitdiffabout
path: root/tests
Unidiff
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rwxr-xr-xtests/setup.sh18
-rwxr-xr-xtests/t0010-validate-html.sh5
-rwxr-xr-xtests/t0101-index.sh6
-rwxr-xr-xtests/t0102-summary.sh6
-rwxr-xr-xtests/t0108-patch.sh37
5 files changed, 61 insertions, 11 deletions
diff --git a/tests/setup.sh b/tests/setup.sh
index 51d5a75..66bf406 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -56,3 +56,5 @@ repo.url=foo
56repo.path=$PWD/trash/repos/foo/.git 56repo.path=$PWD/trash/repos/foo/.git
57repo.desc=the foo repo 57# Do not specify a description for this repo, as it then will be assigned
58# the constant value "[no description]" (which actually used to cause a
59# segfault).
58 60
@@ -67,4 +69,6 @@ prepare_tests()
67 setup_repos 69 setup_repos
70 rm -f test-output.log 2>/dev/null
68 test_count=0 71 test_count=0
69 test_failed=0 72 test_failed=0
73 echo "[$0]" "$@" >test-output.log
70 echo "$@" "($0)" 74 echo "$@" "($0)"
@@ -77,3 +81,4 @@ tests_done()
77 then 81 then
78 printf "[%s of %s tests failed]\n" $test_failed $test_count 82 printf "test: *** %s failure(s), logfile=%s\n" \
83 $test_failed "$(pwd)/test-output.log"
79 false 84 false
@@ -87,10 +92,13 @@ run_test()
87 ((test_count++)) 92 ((test_count++))
88 eval "$2" >test-output.log 93 printf "\ntest %d: name='%s'\n" $test_count "$desc" >>test-output.log
94 printf "test %d: eval='%s'\n" $test_count "$2" >>test-output.log
95 eval "$2" >>test-output.log 2>>test-output.log
89 res=$? 96 res=$?
97 printf "test %d: exitcode=%d\n" $test_count $res >>test-output.log
90 if test $res = 0 98 if test $res = 0
91 then 99 then
92 printf " %s: ok - %s\n" $test_count "$desc" 100 printf " %2d) %-60s [ok]\n" $test_count "$desc"
93 else 101 else
94 ((test_failed++)) 102 ((test_failed++))
95 printf " %s: fail - %s\n" $test_count "$desc" 103 printf " %2d) %-60s [failed]\n" $test_count "$desc"
96 fi 104 fi
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh
index 907a415..94aa52b 100755
--- a/tests/t0010-validate-html.sh
+++ b/tests/t0010-validate-html.sh
@@ -9,5 +9,8 @@ test_url()
9 test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" 9 test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no"
10 cgit_url "$1" | sed -e "1,4d" >trash/tidy-$test_count 10 cgit_url "$1" >trash/tidy-$test_count || return
11 sed -ie "1,4d" trash/tidy-$test_count || return
11 tidy $tidy_opt trash/tidy-$test_count 12 tidy $tidy_opt trash/tidy-$test_count
12 rc=$? 13 rc=$?
14
15 # tidy returns with exitcode 1 on warnings, 2 on error
13 if test $rc = 2 16 if test $rc = 2
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh
index 12ed00c..445af6a 100755
--- a/tests/t0101-index.sh
+++ b/tests/t0101-index.sh
@@ -8,5 +8,7 @@ run_test 'generate index page' 'cgit_url "" >trash/tmp'
8run_test 'find foo repo' 'grep -e "foo" trash/tmp' 8run_test 'find foo repo' 'grep -e "foo" trash/tmp'
9run_test 'find foo description' 'grep -e "\[no description\]" trash/tmp'
9run_test 'find bar repo' 'grep -e "bar" trash/tmp' 10run_test 'find bar repo' 'grep -e "bar" trash/tmp'
10run_test 'no tree-link' 'grep -ve "foo/tree" trash/tmp' 11run_test 'find bar description' 'grep -e "the bar repo" trash/tmp'
11run_test 'no log-link' 'grep -ve "foo/log" trash/tmp' 12run_test 'no tree-link' '! grep -e "foo/tree" trash/tmp'
13run_test 'no log-link' '! grep -e "foo/log" trash/tmp'
12 14
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index 7edd675..f0b0d9a 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -10,6 +10,6 @@ run_test 'find commit 5' 'grep -e "commit 5" trash/tmp'
10run_test 'find branch master' 'grep -e "master" trash/tmp' 10run_test 'find branch master' 'grep -e "master" trash/tmp'
11run_test 'no tags' 'grep -ve "tags" trash/tmp' 11run_test 'no tags' '! grep -e "tags" trash/tmp'
12 12
13run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp' 13run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp'
14run_test 'no commit 45' 'grep -ve "commit 45" trash/tmp' 14run_test 'no commit 45' '! grep -e "commit 45" trash/tmp'
15run_test 'find commit 46' 'grep -e "commit 46" trash/tmp' 15run_test 'find commit 46' 'grep -e "commit 46" trash/tmp'
@@ -17,3 +17,3 @@ run_test 'find commit 50' 'grep -e "commit 50" trash/tmp'
17run_test 'find branch master' 'grep -e "master" trash/tmp' 17run_test 'find branch master' 'grep -e "master" trash/tmp'
18run_test 'no tags' 'grep -ve "tags" trash/tmp' 18run_test 'no tags' '! grep -e "tags" trash/tmp'
19 19
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
new file mode 100755
index 0000000..33351d6
--- a/dev/null
+++ b/tests/t0108-patch.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2
3. ./setup.sh
4
5prepare_tests "Check content on patch page"
6
7run_test 'generate foo/patch' '
8 cgit_query "url=foo/patch" >trash/tmp
9'
10
11run_test 'find `From:` line' '
12 grep -e "^From: " trash/tmp
13'
14
15run_test 'find `Date:` line' '
16 grep -e "^Date: " trash/tmp
17'
18
19run_test 'find `Subject:` line' '
20 grep -e "^Subject: commit 5" trash/tmp
21'
22
23run_test 'find `cgit` signature' '
24 tail -1 trash/tmp | grep -e "^cgit"
25'
26
27run_test 'find initial commit' '
28 root=$(git --git-dir=$PWD/trash/repos/foo/.git rev-list HEAD | tail -1)
29'
30
31run_test 'generate patch for initial commit' '
32 cgit_query "url=foo/patch&id=$root" >trash/tmp
33'
34
35run_test 'find `cgit` signature' '
36 tail -1 trash/tmp | grep -e "^cgit"
37'