diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/setup.sh | 8 | ||||
-rwxr-xr-x | tests/t0010-validate-html.sh | 9 | ||||
-rwxr-xr-x | tests/t0104-tree.sh | 2 | ||||
-rwxr-xr-x | tests/t0107-snapshot.sh | 22 |
4 files changed, 25 insertions, 16 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index 1457dd5..30f90d5 100755 --- a/tests/setup.sh +++ b/tests/setup.sh | |||
@@ -25,11 +25,13 @@ mkrepo() { | |||
25 | mkdir -p $name | 25 | mkdir -p $name |
26 | cd $name | 26 | cd $name |
27 | git init | 27 | git init |
28 | for ((n=1; n<=count; n++)) | 28 | n=1 |
29 | while test $n -le $count | ||
29 | do | 30 | do |
30 | echo $n >file-$n | 31 | echo $n >file-$n |
31 | git add file-$n | 32 | git add file-$n |
32 | git commit -m "commit $n" | 33 | git commit -m "commit $n" |
34 | n=$(expr $n + 1) | ||
33 | done | 35 | done |
34 | if test "$3" = "testplus" | 36 | if test "$3" = "testplus" |
35 | then | 37 | then |
@@ -101,7 +103,7 @@ run_test() | |||
101 | { | 103 | { |
102 | desc=$1 | 104 | desc=$1 |
103 | script=$2 | 105 | script=$2 |
104 | ((test_count++)) | 106 | test_count=$(expr $test_count + 1) |
105 | printf "\ntest %d: name='%s'\n" $test_count "$desc" >>test-output.log | 107 | printf "\ntest %d: name='%s'\n" $test_count "$desc" >>test-output.log |
106 | printf "test %d: eval='%s'\n" $test_count "$2" >>test-output.log | 108 | printf "test %d: eval='%s'\n" $test_count "$2" >>test-output.log |
107 | eval "$2" >>test-output.log 2>>test-output.log | 109 | eval "$2" >>test-output.log 2>>test-output.log |
@@ -111,7 +113,7 @@ run_test() | |||
111 | then | 113 | then |
112 | printf " %2d) %-60s [ok]\n" $test_count "$desc" | 114 | printf " %2d) %-60s [ok]\n" $test_count "$desc" |
113 | else | 115 | else |
114 | ((test_failed++)) | 116 | test_failed=$(expr $test_failed + 1) |
115 | printf " %2d) %-60s [failed]\n" $test_count "$desc" | 117 | printf " %2d) %-60s [failed]\n" $test_count "$desc" |
116 | fi | 118 | fi |
117 | } | 119 | } |
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh index 94aa52b..3fe4800 100755 --- a/tests/t0010-validate-html.sh +++ b/tests/t0010-validate-html.sh | |||
@@ -9,7 +9,7 @@ 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" >trash/tidy-$test_count || return | 10 | cgit_url "$1" >trash/tidy-$test_count || return |
11 | sed -ie "1,4d" trash/tidy-$test_count || return | 11 | sed -ie "1,4d" trash/tidy-$test_count || return |
12 | tidy $tidy_opt trash/tidy-$test_count | 12 | "$tidy" $tidy_opt trash/tidy-$test_count |
13 | rc=$? | 13 | rc=$? |
14 | 14 | ||
15 | # tidy returns with exitcode 1 on warnings, 2 on error | 15 | # tidy returns with exitcode 1 on warnings, 2 on error |
@@ -23,6 +23,13 @@ test_url() | |||
23 | 23 | ||
24 | prepare_tests 'Validate html with tidy' | 24 | prepare_tests 'Validate html with tidy' |
25 | 25 | ||
26 | tidy=`which tidy` | ||
27 | test -n "$tidy" || { | ||
28 | echo "Skipping tests: tidy not found" | ||
29 | tests_done | ||
30 | exit | ||
31 | } | ||
32 | |||
26 | run_test 'index page' 'test_url ""' | 33 | run_test 'index page' 'test_url ""' |
27 | run_test 'foo' 'test_url "foo"' | 34 | run_test 'foo' 'test_url "foo"' |
28 | run_test 'foo/log' 'test_url "foo/log"' | 35 | run_test 'foo/log' 'test_url "foo/log"' |
diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 0d62cc8..33f4eb0 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh | |||
@@ -15,7 +15,7 @@ run_test 'find line 1' ' | |||
15 | ' | 15 | ' |
16 | 16 | ||
17 | run_test 'no line 2' ' | 17 | run_test 'no line 2' ' |
18 | grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp | 18 | ! grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp |
19 | ' | 19 | ' |
20 | 20 | ||
21 | run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' | 21 | run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' |
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index d97c465..8ab4912 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh | |||
@@ -4,36 +4,36 @@ | |||
4 | 4 | ||
5 | prepare_tests "Verify snapshot" | 5 | prepare_tests "Verify snapshot" |
6 | 6 | ||
7 | run_test 'get foo/snapshot/test.tar.gz' ' | 7 | run_test 'get foo/snapshot/master.tar.gz' ' |
8 | cgit_url "foo/snapshot/test.tar.gz" >trash/tmp | 8 | cgit_url "foo/snapshot/master.tar.gz" >trash/tmp |
9 | ' | 9 | ' |
10 | 10 | ||
11 | run_test 'check html headers' ' | 11 | run_test 'check html headers' ' |
12 | head -n 1 trash/tmp | | 12 | head -n 1 trash/tmp | |
13 | grep -e "Content-Type: application/x-tar" && | 13 | grep -e "Content-Type: application/x-gzip" && |
14 | 14 | ||
15 | head -n 2 trash/tmp | | 15 | head -n 2 trash/tmp | |
16 | grep -e "Content-Disposition: inline; filename=.test.tar.gz." | 16 | grep -e "Content-Disposition: inline; filename=.master.tar.gz." |
17 | ' | 17 | ' |
18 | 18 | ||
19 | run_test 'strip off the header lines' ' | 19 | run_test 'strip off the header lines' ' |
20 | tail -n +6 trash/tmp > trash/test.tar.gz | 20 | tail -n +6 trash/tmp > trash/master.tar.gz |
21 | ' | 21 | ' |
22 | 22 | ||
23 | run_test 'verify gzip format' 'gunzip --test trash/test.tar.gz' | 23 | run_test 'verify gzip format' 'gunzip --test trash/master.tar.gz' |
24 | run_test 'untar' ' | 24 | run_test 'untar' ' |
25 | rm -rf trash/foo && | 25 | rm -rf trash/master && |
26 | tar -xf trash/test.tar.gz -C trash | 26 | tar -xf trash/master.tar.gz -C trash |
27 | ' | 27 | ' |
28 | 28 | ||
29 | run_test 'count files' ' | 29 | run_test 'count files' ' |
30 | c=$(ls -1 trash/foo/ | wc -l) && | 30 | c=$(ls -1 trash/master/ | wc -l) && |
31 | test $c = 5 | 31 | test $c = 5 |
32 | ' | 32 | ' |
33 | 33 | ||
34 | run_test 'verify untarred file-5' ' | 34 | run_test 'verify untarred file-5' ' |
35 | grep -e "^5$" trash/foo/file-5 && | 35 | grep -e "^5$" trash/master/file-5 && |
36 | test $(cat trash/foo/file-5 | wc -l) = 1 | 36 | test $(cat trash/master/file-5 | wc -l) = 1 |
37 | ' | 37 | ' |
38 | 38 | ||
39 | tests_done | 39 | tests_done |