summaryrefslogtreecommitdiffabout
path: root/tests
Unidiff
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rwxr-xr-xtests/setup.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/setup.sh b/tests/setup.sh
index 1457dd5..95acb54 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -16,29 +16,31 @@
16# run_test 'repo summary' 'cgit_url "/foo" | tidy -e' 16# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
17 17
18 18
19mkrepo() { 19mkrepo() {
20 name=$1 20 name=$1
21 count=$2 21 count=$2
22 dir=$PWD 22 dir=$PWD
23 test -d $name && return 23 test -d $name && return
24 printf "Creating testrepo %s\n" $name 24 printf "Creating testrepo %s\n" $name
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
36 echo "hello" >a+b 38 echo "hello" >a+b
37 git add a+b 39 git add a+b
38 git commit -m "add a+b" 40 git commit -m "add a+b"
39 git branch "1+2" 41 git branch "1+2"
40 fi 42 fi
41 cd $dir 43 cd $dir
42} 44}
43 45
44setup_repos() 46setup_repos()
@@ -92,25 +94,25 @@ tests_done()
92 if test $test_failed -gt 0 94 if test $test_failed -gt 0
93 then 95 then
94 printf "test: *** %s failure(s), logfile=%s\n" \ 96 printf "test: *** %s failure(s), logfile=%s\n" \
95 $test_failed "$(pwd)/test-output.log" 97 $test_failed "$(pwd)/test-output.log"
96 false 98 false
97 fi 99 fi
98} 100}
99 101
100run_test() 102run_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
108 res=$? 110 res=$?
109 printf "test %d: exitcode=%d\n" $test_count $res >>test-output.log 111 printf "test %d: exitcode=%d\n" $test_count $res >>test-output.log
110 if test $res = 0 112 if test $res = 0
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++))
115 printf " %2d) %-60s [failed]\n" $test_count "$desc" 117 printf " %2d) %-60s [failed]\n" $test_count "$desc"
116 fi 118 fi