1 # This file should be sourced by all test-scripts
4 # prepare_tests(description) - setup for testing, i.e. create repos+config
5 # run_test(description, script) - run one test, i.e. eval script
8 # cgit_query(querystring) - call cgit with the specified querystring
9 # cgit_url(url) - call cgit with the specified virtual url
14 # prepare_tests "html validation"
15 # run_test 'repo index' 'cgit_url "/" | tidy -e'
16 # run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
18 # We don't want to run Git commands through Valgrind, so we filter out the
19 # --valgrind option here and handle it ourselves. We copy the arguments
20 # assuming that none contain a newline, although other whitespace is
29 --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
31 test_argv
="$test_argv${LF}--verbose"
34 test_argv
="$test_argv$LF$1"
45 : ${TEST_DIRECTORY=$(pwd)/../git/t}
46 : ${TEST_OUTPUT_DIRECTORY=$(pwd)}
47 TEST_NO_CREATE_REPO
=YesPlease
48 .
"$TEST_DIRECTORY"/test-lib.sh
50 # Prepend the directory containing cgit to PATH.
51 if test -n "$cgit_valgrind"
53 GIT_VALGRIND
="$TEST_DIRECTORY/valgrind"
54 CGIT_VALGRIND
=$(cd ../valgrind && pwd)
55 PATH
="$CGIT_VALGRIND/bin:$PATH"
56 export GIT_VALGRIND CGIT_VALGRIND
58 PATH
="$(pwd)/../..:$PATH"
61 FILTER_DIRECTORY
=$(cd ../filters && pwd)
63 if cgit
--version | grep -F -q "[+] Lua scripting"; then
72 test_create_repo
"$name"
76 while test $n -le $count
80 git commit
-m "commit $n"
83 if test "$3" = "testplus"
87 git commit
-m "add a+b"
97 mkrepo repos
/foo
5 >/dev
/null
98 mkrepo repos
/bar
50 >/dev
/null
99 mkrepo repos
/foo
+bar
10 testplus
>/dev
/null
100 mkrepo
"repos/with space" 2 >/dev
/null
101 mkrepo repos
/filter
5 testplus
>/dev
/null
104 cache-root=$PWD/cache
107 snapshots=tar.gz tar.bz zip
108 enable-log-filecount=1
109 enable-log-linecount=1
113 clone-url=git://example.org/\$CGIT_REPO_URL.git
114 enable-filter-overrides=1
117 repo.path=$PWD/repos/foo/.git
118 # Do not specify a description for this repo, as it then will be assigned
119 # the constant value "[no description]" (which actually used to cause a
123 repo.path=$PWD/repos/bar/.git
124 repo.desc=the bar repo
127 repo.path=$PWD/repos/foo+bar/.git
128 repo.desc=the foo+bar repo
131 repo.path=$PWD/repos/with space/.git
132 repo.desc=spaced repo
135 repo.path=$PWD/repos/filter/.git
136 repo.desc=filtered repo
137 repo.about-filter=exec:$FILTER_DIRECTORY/dump.sh
138 repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh
139 repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh
140 repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh
141 repo.readme=master:a+b
144 if [ $CGIT_HAS_LUA -eq 1 ]; then
147 repo.path=$PWD/repos/filter/.git
148 repo.desc=filtered repo
149 repo.about-filter=lua:$FILTER_DIRECTORY/dump.lua
150 repo.commit-filter=lua:$FILTER_DIRECTORY/dump.lua
151 repo.email-filter=lua:$FILTER_DIRECTORY/dump.lua
152 repo.source-filter=lua:$FILTER_DIRECTORY/dump.lua
153 repo.readme=master:a+b
160 CGIT_CONFIG
="$PWD/cgitrc" QUERY_STRING
="$1" cgit
165 CGIT_CONFIG
="$PWD/cgitrc" QUERY_STRING
="url=$1" cgit
171 test -z "$line" && break
176 test -z "$CGIT_TEST_NO_CREATE_REPOS" && setup_repos