Combine To: and Cc: headers
[git/raj.git] / t / t9500-gitweb-standalone-no-errors.sh
blob796cd7dba0cdc64e6b9e68e81663e9a70327d8e5
1 #!/bin/sh
3 # Copyright (c) 2007 Jakub Narebski
6 test_description='gitweb as standalone script (basic tests).
8 This test runs gitweb (git web interface) as CGI script from
9 commandline, and checks that it would not write any errors
10 or warnings to log.'
12 gitweb_init () {
13 cat >gitweb_config.perl <<EOF
14 #!/usr/bin/perl
16 # gitweb configuration for tests
18 our \$version = "current";
19 our \$GIT = "git";
20 our \$projectroot = "$(pwd)";
21 our \$project_maxdepth = 8;
22 our \$home_link_str = "projects";
23 our \$site_name = "[localhost]";
24 our \$site_header = "";
25 our \$site_footer = "";
26 our \$home_text = "indextext.html";
27 our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
28 our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
29 our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
30 our \$projects_list = "";
31 our \$export_ok = "";
32 our \$strict_export = "";
34 EOF
36 cat >.git/description <<EOF
37 $0 test repository
38 EOF
41 gitweb_run () {
42 export GATEWAY_INTERFACE="CGI/1.1"
43 export HTTP_ACCEPT="*/*"
44 export REQUEST_METHOD="GET"
45 export QUERY_STRING=""$1""
46 export PATH_INFO=""$2""
48 export GITWEB_CONFIG=$(pwd)/gitweb_config.perl
50 # some of git commands write to STDERR on error, but this is not
51 # written to web server logs, so we are not interested in that:
52 # we are interested only in properly formatted errors/warnings
53 rm -f gitweb.log &&
54 perl -- $(pwd)/../../gitweb/gitweb.perl \
55 >/dev/null 2>gitweb.log &&
56 if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
58 # gitweb.log is left for debugging
61 safe_chmod () {
62 chmod "$1" "$2" &&
63 if [ "$(git config --get core.filemode)" = false ]
64 then
65 git update-index --chmod="$1" "$2"
69 . ./test-lib.sh
71 perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
72 test_expect_success 'skipping gitweb tests, perl version is too old' :
73 test_done
74 exit
77 gitweb_init
79 # ----------------------------------------------------------------------
80 # no commits (empty, just initialized repository)
82 test_expect_success \
83 'no commits: projects_list (implicit)' \
84 'gitweb_run'
85 test_debug 'cat gitweb.log'
87 test_expect_success \
88 'no commits: projects_index' \
89 'gitweb_run "a=project_index"'
90 test_debug 'cat gitweb.log'
92 test_expect_success \
93 'no commits: .git summary (implicit)' \
94 'gitweb_run "p=.git"'
95 test_debug 'cat gitweb.log'
97 test_expect_success \
98 'no commits: .git commit (implicit HEAD)' \
99 'gitweb_run "p=.git;a=commit"'
100 test_debug 'cat gitweb.log'
102 test_expect_success \
103 'no commits: .git commitdiff (implicit HEAD)' \
104 'gitweb_run "p=.git;a=commitdiff"'
105 test_debug 'cat gitweb.log'
107 test_expect_success \
108 'no commits: .git tree (implicit HEAD)' \
109 'gitweb_run "p=.git;a=tree"'
110 test_debug 'cat gitweb.log'
112 test_expect_success \
113 'no commits: .git heads' \
114 'gitweb_run "p=.git;a=heads"'
115 test_debug 'cat gitweb.log'
117 test_expect_success \
118 'no commits: .git tags' \
119 'gitweb_run "p=.git;a=tags"'
120 test_debug 'cat gitweb.log'
123 # ----------------------------------------------------------------------
124 # initial commit
126 test_expect_success \
127 'Make initial commit' \
128 'echo "Not an empty file." > file &&
129 git add file &&
130 git commit -a -m "Initial commit." &&
131 git branch b'
133 test_expect_success \
134 'projects_list (implicit)' \
135 'gitweb_run'
136 test_debug 'cat gitweb.log'
138 test_expect_success \
139 'projects_index' \
140 'gitweb_run "a=project_index"'
141 test_debug 'cat gitweb.log'
143 test_expect_success \
144 '.git summary (implicit)' \
145 'gitweb_run "p=.git"'
146 test_debug 'cat gitweb.log'
148 test_expect_success \
149 '.git commit (implicit HEAD)' \
150 'gitweb_run "p=.git;a=commit"'
151 test_debug 'cat gitweb.log'
153 test_expect_success \
154 '.git commitdiff (implicit HEAD, root commit)' \
155 'gitweb_run "p=.git;a=commitdiff"'
156 test_debug 'cat gitweb.log'
158 test_expect_success \
159 '.git commitdiff_plain (implicit HEAD, root commit)' \
160 'gitweb_run "p=.git;a=commitdiff_plain"'
161 test_debug 'cat gitweb.log'
163 test_expect_success \
164 '.git commit (HEAD)' \
165 'gitweb_run "p=.git;a=commit;h=HEAD"'
166 test_debug 'cat gitweb.log'
168 test_expect_success \
169 '.git tree (implicit HEAD)' \
170 'gitweb_run "p=.git;a=tree"'
171 test_debug 'cat gitweb.log'
173 test_expect_success \
174 '.git blob (file)' \
175 'gitweb_run "p=.git;a=blob;f=file"'
176 test_debug 'cat gitweb.log'
178 test_expect_success \
179 '.git blob_plain (file)' \
180 'gitweb_run "p=.git;a=blob_plain;f=file"'
181 test_debug 'cat gitweb.log'
183 # ----------------------------------------------------------------------
184 # nonexistent objects
186 test_expect_success \
187 '.git commit (non-existent)' \
188 'gitweb_run "p=.git;a=commit;h=non-existent"'
189 test_debug 'cat gitweb.log'
191 test_expect_success \
192 '.git commitdiff (non-existent)' \
193 'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
194 test_debug 'cat gitweb.log'
196 test_expect_success \
197 '.git commitdiff (non-existent vs HEAD)' \
198 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
199 test_debug 'cat gitweb.log'
201 test_expect_success \
202 '.git tree (0000000000000000000000000000000000000000)' \
203 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
204 test_debug 'cat gitweb.log'
206 test_expect_success \
207 '.git tag (0000000000000000000000000000000000000000)' \
208 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
209 test_debug 'cat gitweb.log'
211 test_expect_success \
212 '.git blob (non-existent)' \
213 'gitweb_run "p=.git;a=blob;f=non-existent"'
214 test_debug 'cat gitweb.log'
216 test_expect_success \
217 '.git blob_plain (non-existent)' \
218 'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
219 test_debug 'cat gitweb.log'
222 # ----------------------------------------------------------------------
223 # commitdiff testing (implicit, one implicit tree-ish)
225 test_expect_success \
226 'commitdiff(0): root' \
227 'gitweb_run "p=.git;a=commitdiff"'
228 test_debug 'cat gitweb.log'
230 test_expect_success \
231 'commitdiff(0): file added' \
232 'echo "New file" > new_file &&
233 git add new_file &&
234 git commit -a -m "File added." &&
235 gitweb_run "p=.git;a=commitdiff"'
236 test_debug 'cat gitweb.log'
238 test_expect_success \
239 'commitdiff(0): mode change' \
240 'safe_chmod +x new_file &&
241 git commit -a -m "Mode changed." &&
242 gitweb_run "p=.git;a=commitdiff"'
243 test_debug 'cat gitweb.log'
245 test_expect_success \
246 'commitdiff(0): file renamed' \
247 'git mv new_file renamed_file &&
248 git commit -a -m "File renamed." &&
249 gitweb_run "p=.git;a=commitdiff"'
250 test_debug 'cat gitweb.log'
252 test_expect_success \
253 'commitdiff(0): file to symlink' \
254 'rm renamed_file &&
255 ln -s file renamed_file &&
256 git commit -a -m "File to symlink." &&
257 gitweb_run "p=.git;a=commitdiff"'
258 test_debug 'cat gitweb.log'
260 test_expect_success \
261 'commitdiff(0): file deleted' \
262 'git rm renamed_file &&
263 rm -f renamed_file &&
264 git commit -a -m "File removed." &&
265 gitweb_run "p=.git;a=commitdiff"'
266 test_debug 'cat gitweb.log'
268 test_expect_success \
269 'commitdiff(0): file copied / new file' \
270 'cp file file2 &&
271 git add file2 &&
272 git commit -a -m "File copied." &&
273 gitweb_run "p=.git;a=commitdiff"'
274 test_debug 'cat gitweb.log'
276 test_expect_success \
277 'commitdiff(0): mode change and modified' \
278 'echo "New line" >> file2 &&
279 safe_chmod +x file2 &&
280 git commit -a -m "Mode change and modification." &&
281 gitweb_run "p=.git;a=commitdiff"'
282 test_debug 'cat gitweb.log'
284 test_expect_success \
285 'commitdiff(0): renamed and modified' \
286 'cat >file2<<EOF &&
287 Dominus regit me,
288 et nihil mihi deerit.
289 In loco pascuae ibi me collocavit,
290 super aquam refectionis educavit me;
291 animam meam convertit,
292 deduxit me super semitas jusitiae,
293 propter nomen suum.
295 git commit -a -m "File added." &&
296 git mv file2 file3 &&
297 echo "Propter nomen suum." >> file3 &&
298 git commit -a -m "File rename and modification." &&
299 gitweb_run "p=.git;a=commitdiff"'
300 test_debug 'cat gitweb.log'
302 test_expect_success \
303 'commitdiff(0): renamed, mode change and modified' \
304 'git mv file3 file2 &&
305 echo "Propter nomen suum." >> file2 &&
306 safe_chmod +x file2 &&
307 git commit -a -m "File rename, mode change and modification." &&
308 gitweb_run "p=.git;a=commitdiff"'
309 test_debug 'cat gitweb.log'
311 # ----------------------------------------------------------------------
312 # commitdiff testing (taken from t4114-apply-typechange.sh)
314 test_expect_success 'setup typechange commits' '
315 echo "hello world" > foo &&
316 echo "hi planet" > bar &&
317 git update-index --add foo bar &&
318 git commit -m initial &&
319 git branch initial &&
320 rm -f foo &&
321 ln -s bar foo &&
322 git update-index foo &&
323 git commit -m "foo symlinked to bar" &&
324 git branch foo-symlinked-to-bar &&
325 rm -f foo &&
326 echo "how far is the sun?" > foo &&
327 git update-index foo &&
328 git commit -m "foo back to file" &&
329 git branch foo-back-to-file &&
330 rm -f foo &&
331 git update-index --remove foo &&
332 mkdir foo &&
333 echo "if only I knew" > foo/baz &&
334 git update-index --add foo/baz &&
335 git commit -m "foo becomes a directory" &&
336 git branch "foo-becomes-a-directory" &&
337 echo "hello world" > foo/baz &&
338 git update-index foo/baz &&
339 git commit -m "foo/baz is the original foo" &&
340 git branch foo-baz-renamed-from-foo
343 test_expect_success \
344 'commitdiff(2): file renamed from foo to foo/baz' \
345 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
346 test_debug 'cat gitweb.log'
348 test_expect_success \
349 'commitdiff(2): file renamed from foo/baz to foo' \
350 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
351 test_debug 'cat gitweb.log'
353 test_expect_success \
354 'commitdiff(2): directory becomes file' \
355 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
356 test_debug 'cat gitweb.log'
358 test_expect_success \
359 'commitdiff(2): file becomes directory' \
360 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
361 test_debug 'cat gitweb.log'
363 test_expect_success \
364 'commitdiff(2): file becomes symlink' \
365 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
366 test_debug 'cat gitweb.log'
368 test_expect_success \
369 'commitdiff(2): symlink becomes file' \
370 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
371 test_debug 'cat gitweb.log'
373 test_expect_success \
374 'commitdiff(2): symlink becomes directory' \
375 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
376 test_debug 'cat gitweb.log'
378 test_expect_success \
379 'commitdiff(2): directory becomes symlink' \
380 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
381 test_debug 'cat gitweb.log'
383 # ----------------------------------------------------------------------
384 # commit, commitdiff: merge, large
385 test_expect_success \
386 'Create a merge' \
387 'git checkout b &&
388 echo "Branch" >> b &&
389 git add b &&
390 git commit -a -m "On branch" &&
391 git checkout master &&
392 git pull . b'
394 test_expect_success \
395 'commit(0): merge commit' \
396 'gitweb_run "p=.git;a=commit"'
397 test_debug 'cat gitweb.log'
399 test_expect_success \
400 'commitdiff(0): merge commit' \
401 'gitweb_run "p=.git;a=commitdiff"'
402 test_debug 'cat gitweb.log'
404 test_expect_success \
405 'Prepare large commit' \
406 'git checkout b &&
407 echo "To be changed" > 01-change &&
408 echo "To be renamed" > 02-pure-rename-from &&
409 echo "To be deleted" > 03-delete &&
410 echo "To be renamed and changed" > 04-rename-from &&
411 echo "To have mode changed" > 05-mode-change &&
412 echo "File to symlink" > 06-file-or-symlink &&
413 echo "To be changed and have mode changed" > 07-change-mode-change &&
414 git add 0* &&
415 git commit -a -m "Prepare large commit" &&
416 echo "Changed" > 01-change &&
417 git mv 02-pure-rename-from 02-pure-rename-to &&
418 git rm 03-delete && rm -f 03-delete &&
419 echo "A new file" > 03-new &&
420 git add 03-new &&
421 git mv 04-rename-from 04-rename-to &&
422 echo "Changed" >> 04-rename-to &&
423 safe_chmod +x 05-mode-change &&
424 rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
425 echo "Changed and have mode changed" > 07-change-mode-change &&
426 safe_chmod +x 07-change-mode-change &&
427 git commit -a -m "Large commit" &&
428 git checkout master'
430 test_expect_success \
431 'commit(1): large commit' \
432 'gitweb_run "p=.git;a=commit;h=b"'
433 test_debug 'cat gitweb.log'
435 test_expect_success \
436 'commitdiff(1): large commit' \
437 'gitweb_run "p=.git;a=commitdiff;h=b"'
438 test_debug 'cat gitweb.log'
440 # ----------------------------------------------------------------------
441 # tags testing
443 test_expect_success \
444 'tags: list of different types of tags' \
445 'git checkout master &&
446 git tag -a -m "Tag commit object" tag-commit HEAD &&
447 git tag -a -m "" tag-commit-nomessage HEAD &&
448 git tag -a -m "Tag tag object" tag-tag tag-commit &&
449 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
450 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
451 git tag lightweight/tag-commit HEAD &&
452 git tag lightweight/tag-tag tag-commit &&
453 git tag lightweight/tag-tree HEAD^{tree} &&
454 git tag lightweight/tag-blob HEAD:file &&
455 gitweb_run "p=.git;a=tags"'
456 test_debug 'cat gitweb.log'
458 test_expect_success \
459 'tag: Tag to commit object' \
460 'gitweb_run "p=.git;a=tag;h=tag-commit"'
461 test_debug 'cat gitweb.log'
463 test_expect_success \
464 'tag: on lightweight tag (invalid)' \
465 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
466 test_debug 'cat gitweb.log'
468 # ----------------------------------------------------------------------
469 # logs
471 test_expect_success \
472 'logs: log (implicit HEAD)' \
473 'gitweb_run "p=.git;a=log"'
474 test_debug 'cat gitweb.log'
476 test_expect_success \
477 'logs: shortlog (implicit HEAD)' \
478 'gitweb_run "p=.git;a=shortlog"'
479 test_debug 'cat gitweb.log'
481 test_expect_success \
482 'logs: history (implicit HEAD, file)' \
483 'gitweb_run "p=.git;a=history;f=file"'
484 test_debug 'cat gitweb.log'
486 # ----------------------------------------------------------------------
487 # feed generation
489 test_expect_success \
490 'feeds: OPML' \
491 'gitweb_run "a=opml"'
492 test_debug 'cat gitweb.log'
494 test_expect_success \
495 'feed: RSS' \
496 'gitweb_run "p=.git;a=rss"'
497 test_debug 'cat gitweb.log'
499 test_expect_success \
500 'feed: Atom' \
501 'gitweb_run "p=.git;a=atom"'
502 test_debug 'cat gitweb.log'
504 # ----------------------------------------------------------------------
505 # encoding/decoding
507 test_expect_success \
508 'encode(commit): utf8' \
509 '. ../t3901-utf8.txt &&
510 echo "UTF-8" >> file &&
511 git add file &&
512 git commit -F ../t3900/1-UTF-8.txt &&
513 gitweb_run "p=.git;a=commit"'
514 test_debug 'cat gitweb.log'
516 test_expect_success \
517 'encode(commit): iso-8859-1' \
518 '. ../t3901-8859-1.txt &&
519 echo "ISO-8859-1" >> file &&
520 git add file &&
521 git config i18n.commitencoding ISO-8859-1 &&
522 git commit -F ../t3900/ISO-8859-1.txt &&
523 git config --unset i18n.commitencoding &&
524 gitweb_run "p=.git;a=commit"'
525 test_debug 'cat gitweb.log'
527 test_expect_success \
528 'encode(log): utf-8 and iso-8859-1' \
529 'gitweb_run "p=.git;a=log"'
530 test_debug 'cat gitweb.log'
532 # ----------------------------------------------------------------------
533 # extra options
535 test_expect_success \
536 'opt: log --no-merges' \
537 'gitweb_run "p=.git;a=log;opt=--no-merges"'
538 test_debug 'cat gitweb.log'
540 test_expect_success \
541 'opt: atom --no-merges' \
542 'gitweb_run "p=.git;a=log;opt=--no-merges"'
543 test_debug 'cat gitweb.log'
545 test_expect_success \
546 'opt: "file" history --no-merges' \
547 'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
548 test_debug 'cat gitweb.log'
550 test_expect_success \
551 'opt: log --no-such-option (invalid option)' \
552 'gitweb_run "p=.git;a=log;opt=--no-such-option"'
553 test_debug 'cat gitweb.log'
555 test_expect_success \
556 'opt: tree --no-merges (invalid option for action)' \
557 'gitweb_run "p=.git;a=tree;opt=--no-merges"'
558 test_debug 'cat gitweb.log'
560 # ----------------------------------------------------------------------
561 # testing config_to_multi / cloneurl
563 test_expect_success \
564 'URL: no project URLs, no base URL' \
565 'gitweb_run "p=.git;a=summary"'
566 test_debug 'cat gitweb.log'
568 test_expect_success \
569 'URL: project URLs via gitweb.url' \
570 'git config --add gitweb.url git://example.com/git/trash.git &&
571 git config --add gitweb.url http://example.com/git/trash.git &&
572 gitweb_run "p=.git;a=summary"'
573 test_debug 'cat gitweb.log'
575 cat >.git/cloneurl <<\EOF
576 git://example.com/git/trash.git
577 http://example.com/git/trash.git
580 test_expect_success \
581 'URL: project URLs via cloneurl file' \
582 'gitweb_run "p=.git;a=summary"'
583 test_debug 'cat gitweb.log'
585 # ----------------------------------------------------------------------
586 # gitweb config and repo config
588 cat >>gitweb_config.perl <<EOF
590 \$feature{'blame'}{'override'} = 1;
591 \$feature{'snapshot'}{'override'} = 1;
594 test_expect_success \
595 'config override: tree view, features disabled in repo config' \
596 'git config gitweb.blame no &&
597 git config gitweb.snapshot none &&
598 gitweb_run "p=.git;a=tree"'
599 test_debug 'cat gitweb.log'
601 test_expect_success \
602 'config override: tree view, features enabled in repo config' \
603 'git config gitweb.blame yes &&
604 git config gitweb.snapshot "zip,tgz, tbz2" &&
605 gitweb_run "p=.git;a=tree"'
606 test_debug 'cat gitweb.log'
608 test_done