Merge branch 'mm/phrase-remote-tracking'
[git/kirr.git] / t / t9500-gitweb-standalone-no-errors.sh
blob21cd286bb7abf33c944a8758ce8d702e83ca2022
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.'
13 . ./gitweb-lib.sh
15 # ----------------------------------------------------------------------
16 # no commits (empty, just initialized repository)
18 test_expect_success \
19 'no commits: projects_list (implicit)' \
20 'gitweb_run'
21 test_debug 'cat gitweb.log'
23 test_expect_success \
24 'no commits: projects_index' \
25 'gitweb_run "a=project_index"'
26 test_debug 'cat gitweb.log'
28 test_expect_success \
29 'no commits: .git summary (implicit)' \
30 'gitweb_run "p=.git"'
31 test_debug 'cat gitweb.log'
33 test_expect_success \
34 'no commits: .git commit (implicit HEAD)' \
35 'gitweb_run "p=.git;a=commit"'
36 test_debug 'cat gitweb.log'
38 test_expect_success \
39 'no commits: .git commitdiff (implicit HEAD)' \
40 'gitweb_run "p=.git;a=commitdiff"'
41 test_debug 'cat gitweb.log'
43 test_expect_success \
44 'no commits: .git tree (implicit HEAD)' \
45 'gitweb_run "p=.git;a=tree"'
46 test_debug 'cat gitweb.log'
48 test_expect_success \
49 'no commits: .git heads' \
50 'gitweb_run "p=.git;a=heads"'
51 test_debug 'cat gitweb.log'
53 test_expect_success \
54 'no commits: .git tags' \
55 'gitweb_run "p=.git;a=tags"'
56 test_debug 'cat gitweb.log'
59 # ----------------------------------------------------------------------
60 # initial commit
62 test_expect_success \
63 'Make initial commit' \
64 'echo "Not an empty file." > file &&
65 git add file &&
66 git commit -a -m "Initial commit." &&
67 git branch b'
69 test_expect_success \
70 'projects_list (implicit)' \
71 'gitweb_run'
72 test_debug 'cat gitweb.log'
74 test_expect_success \
75 'projects_index' \
76 'gitweb_run "a=project_index"'
77 test_debug 'cat gitweb.log'
79 test_expect_success \
80 '.git summary (implicit)' \
81 'gitweb_run "p=.git"'
82 test_debug 'cat gitweb.log'
84 test_expect_success \
85 '.git commit (implicit HEAD)' \
86 'gitweb_run "p=.git;a=commit"'
87 test_debug 'cat gitweb.log'
89 test_expect_success \
90 '.git commitdiff (implicit HEAD, root commit)' \
91 'gitweb_run "p=.git;a=commitdiff"'
92 test_debug 'cat gitweb.log'
94 test_expect_success \
95 '.git commitdiff_plain (implicit HEAD, root commit)' \
96 'gitweb_run "p=.git;a=commitdiff_plain"'
97 test_debug 'cat gitweb.log'
99 test_expect_success \
100 '.git commit (HEAD)' \
101 'gitweb_run "p=.git;a=commit;h=HEAD"'
102 test_debug 'cat gitweb.log'
104 test_expect_success \
105 '.git tree (implicit HEAD)' \
106 'gitweb_run "p=.git;a=tree"'
107 test_debug 'cat gitweb.log'
109 test_expect_success \
110 '.git blob (file)' \
111 'gitweb_run "p=.git;a=blob;f=file"'
112 test_debug 'cat gitweb.log'
114 test_expect_success \
115 '.git blob_plain (file)' \
116 'gitweb_run "p=.git;a=blob_plain;f=file"'
117 test_debug 'cat gitweb.log'
119 # ----------------------------------------------------------------------
120 # nonexistent objects
122 test_expect_success \
123 '.git commit (non-existent)' \
124 'gitweb_run "p=.git;a=commit;h=non-existent"'
125 test_debug 'cat gitweb.log'
127 test_expect_success \
128 '.git commitdiff (non-existent)' \
129 'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
130 test_debug 'cat gitweb.log'
132 test_expect_success \
133 '.git commitdiff (non-existent vs HEAD)' \
134 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
135 test_debug 'cat gitweb.log'
137 test_expect_success \
138 '.git tree (0000000000000000000000000000000000000000)' \
139 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
140 test_debug 'cat gitweb.log'
142 test_expect_success \
143 '.git tag (0000000000000000000000000000000000000000)' \
144 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
145 test_debug 'cat gitweb.log'
147 test_expect_success \
148 '.git blob (non-existent)' \
149 'gitweb_run "p=.git;a=blob;f=non-existent"'
150 test_debug 'cat gitweb.log'
152 test_expect_success \
153 '.git blob_plain (non-existent)' \
154 'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
155 test_debug 'cat gitweb.log'
158 # ----------------------------------------------------------------------
159 # commitdiff testing (implicit, one implicit tree-ish)
161 test_expect_success \
162 'commitdiff(0): root' \
163 'gitweb_run "p=.git;a=commitdiff"'
164 test_debug 'cat gitweb.log'
166 test_expect_success \
167 'commitdiff(0): file added' \
168 'echo "New file" > new_file &&
169 git add new_file &&
170 git commit -a -m "File added." &&
171 gitweb_run "p=.git;a=commitdiff"'
172 test_debug 'cat gitweb.log'
174 test_expect_success \
175 'commitdiff(0): mode change' \
176 'test_chmod +x new_file &&
177 git commit -a -m "Mode changed." &&
178 gitweb_run "p=.git;a=commitdiff"'
179 test_debug 'cat gitweb.log'
181 test_expect_success \
182 'commitdiff(0): file renamed' \
183 'git mv new_file renamed_file &&
184 git commit -a -m "File renamed." &&
185 gitweb_run "p=.git;a=commitdiff"'
186 test_debug 'cat gitweb.log'
188 test_expect_success SYMLINKS \
189 'commitdiff(0): file to symlink' \
190 'rm renamed_file &&
191 ln -s file renamed_file &&
192 git commit -a -m "File to symlink." &&
193 gitweb_run "p=.git;a=commitdiff"'
194 test_debug 'cat gitweb.log'
196 test_expect_success \
197 'commitdiff(0): file deleted' \
198 'git rm renamed_file &&
199 rm -f renamed_file &&
200 git commit -a -m "File removed." &&
201 gitweb_run "p=.git;a=commitdiff"'
202 test_debug 'cat gitweb.log'
204 test_expect_success \
205 'commitdiff(0): file copied / new file' \
206 'cp file file2 &&
207 git add file2 &&
208 git commit -a -m "File copied." &&
209 gitweb_run "p=.git;a=commitdiff"'
210 test_debug 'cat gitweb.log'
212 test_expect_success \
213 'commitdiff(0): mode change and modified' \
214 'echo "New line" >> file2 &&
215 test_chmod +x file2 &&
216 git commit -a -m "Mode change and modification." &&
217 gitweb_run "p=.git;a=commitdiff"'
218 test_debug 'cat gitweb.log'
220 test_expect_success \
221 'commitdiff(0): renamed and modified' \
222 'cat >file2<<EOF &&
223 Dominus regit me,
224 et nihil mihi deerit.
225 In loco pascuae ibi me collocavit,
226 super aquam refectionis educavit me;
227 animam meam convertit,
228 deduxit me super semitas jusitiae,
229 propter nomen suum.
231 git commit -a -m "File added." &&
232 git mv file2 file3 &&
233 echo "Propter nomen suum." >> file3 &&
234 git commit -a -m "File rename and modification." &&
235 gitweb_run "p=.git;a=commitdiff"'
236 test_debug 'cat gitweb.log'
238 test_expect_success \
239 'commitdiff(0): renamed, mode change and modified' \
240 'git mv file3 file2 &&
241 echo "Propter nomen suum." >> file2 &&
242 test_chmod +x file2 &&
243 git commit -a -m "File rename, mode change and modification." &&
244 gitweb_run "p=.git;a=commitdiff"'
245 test_debug 'cat gitweb.log'
247 # ----------------------------------------------------------------------
248 # commitdiff testing (taken from t4114-apply-typechange.sh)
250 test_expect_success SYMLINKS 'setup typechange commits' '
251 echo "hello world" > foo &&
252 echo "hi planet" > bar &&
253 git update-index --add foo bar &&
254 git commit -m initial &&
255 git branch initial &&
256 rm -f foo &&
257 ln -s bar foo &&
258 git update-index foo &&
259 git commit -m "foo symlinked to bar" &&
260 git branch foo-symlinked-to-bar &&
261 rm -f foo &&
262 echo "how far is the sun?" > foo &&
263 git update-index foo &&
264 git commit -m "foo back to file" &&
265 git branch foo-back-to-file &&
266 rm -f foo &&
267 git update-index --remove foo &&
268 mkdir foo &&
269 echo "if only I knew" > foo/baz &&
270 git update-index --add foo/baz &&
271 git commit -m "foo becomes a directory" &&
272 git branch "foo-becomes-a-directory" &&
273 echo "hello world" > foo/baz &&
274 git update-index foo/baz &&
275 git commit -m "foo/baz is the original foo" &&
276 git branch foo-baz-renamed-from-foo
279 test_expect_success \
280 'commitdiff(2): file renamed from foo to foo/baz' \
281 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
282 test_debug 'cat gitweb.log'
284 test_expect_success \
285 'commitdiff(2): file renamed from foo/baz to foo' \
286 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
287 test_debug 'cat gitweb.log'
289 test_expect_success \
290 'commitdiff(2): directory becomes file' \
291 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
292 test_debug 'cat gitweb.log'
294 test_expect_success \
295 'commitdiff(2): file becomes directory' \
296 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
297 test_debug 'cat gitweb.log'
299 test_expect_success \
300 'commitdiff(2): file becomes symlink' \
301 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
302 test_debug 'cat gitweb.log'
304 test_expect_success \
305 'commitdiff(2): symlink becomes file' \
306 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
307 test_debug 'cat gitweb.log'
309 test_expect_success \
310 'commitdiff(2): symlink becomes directory' \
311 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
312 test_debug 'cat gitweb.log'
314 test_expect_success \
315 'commitdiff(2): directory becomes symlink' \
316 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
317 test_debug 'cat gitweb.log'
319 # ----------------------------------------------------------------------
320 # commit, commitdiff: merge, large
321 test_expect_success \
322 'Create a merge' \
323 'git checkout b &&
324 echo "Branch" >> b &&
325 git add b &&
326 git commit -a -m "On branch" &&
327 git checkout master &&
328 git pull . b'
330 test_expect_success \
331 'commit(0): merge commit' \
332 'gitweb_run "p=.git;a=commit"'
333 test_debug 'cat gitweb.log'
335 test_expect_success \
336 'commitdiff(0): merge commit' \
337 'gitweb_run "p=.git;a=commitdiff"'
338 test_debug 'cat gitweb.log'
340 test_expect_success \
341 'Prepare large commit' \
342 'git checkout b &&
343 echo "To be changed" > 01-change &&
344 echo "To be renamed" > 02-pure-rename-from &&
345 echo "To be deleted" > 03-delete &&
346 echo "To be renamed and changed" > 04-rename-from &&
347 echo "To have mode changed" > 05-mode-change &&
348 echo "File to symlink" > 06-file-or-symlink &&
349 echo "To be changed and have mode changed" > 07-change-mode-change &&
350 git add 0* &&
351 git commit -a -m "Prepare large commit" &&
352 echo "Changed" > 01-change &&
353 git mv 02-pure-rename-from 02-pure-rename-to &&
354 git rm 03-delete && rm -f 03-delete &&
355 echo "A new file" > 03-new &&
356 git add 03-new &&
357 git mv 04-rename-from 04-rename-to &&
358 echo "Changed" >> 04-rename-to &&
359 test_chmod +x 05-mode-change &&
360 rm -f 06-file-or-symlink &&
361 if test_have_prereq SYMLINKS; then
362 ln -s 01-change 06-file-or-symlink
363 else
364 printf %s 01-change > 06-file-or-symlink
365 fi &&
366 echo "Changed and have mode changed" > 07-change-mode-change &&
367 test_chmod +x 07-change-mode-change &&
368 git commit -a -m "Large commit" &&
369 git checkout master'
371 test_expect_success \
372 'commit(1): large commit' \
373 'gitweb_run "p=.git;a=commit;h=b"'
374 test_debug 'cat gitweb.log'
376 test_expect_success \
377 'commitdiff(1): large commit' \
378 'gitweb_run "p=.git;a=commitdiff;h=b"'
379 test_debug 'cat gitweb.log'
381 # ----------------------------------------------------------------------
382 # tags testing
384 test_expect_success \
385 'tags: list of different types of tags' \
386 'git checkout master &&
387 git tag -a -m "Tag commit object" tag-commit HEAD &&
388 git tag -a -m "" tag-commit-nomessage HEAD &&
389 git tag -a -m "Tag tag object" tag-tag tag-commit &&
390 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
391 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
392 git tag lightweight/tag-commit HEAD &&
393 git tag lightweight/tag-tag tag-commit &&
394 git tag lightweight/tag-tree HEAD^{tree} &&
395 git tag lightweight/tag-blob HEAD:file &&
396 gitweb_run "p=.git;a=tags"'
397 test_debug 'cat gitweb.log'
399 test_expect_success \
400 'tag: Tag to commit object' \
401 'gitweb_run "p=.git;a=tag;h=tag-commit"'
402 test_debug 'cat gitweb.log'
404 test_expect_success \
405 'tag: on lightweight tag (invalid)' \
406 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
407 test_debug 'cat gitweb.log'
409 # ----------------------------------------------------------------------
410 # logs
412 test_expect_success \
413 'logs: log (implicit HEAD)' \
414 'gitweb_run "p=.git;a=log"'
415 test_debug 'cat gitweb.log'
417 test_expect_success \
418 'logs: shortlog (implicit HEAD)' \
419 'gitweb_run "p=.git;a=shortlog"'
420 test_debug 'cat gitweb.log'
422 test_expect_success \
423 'logs: history (implicit HEAD, file)' \
424 'gitweb_run "p=.git;a=history;f=file"'
425 test_debug 'cat gitweb.log'
427 test_expect_success \
428 'logs: history (implicit HEAD, non-existent file)' \
429 'gitweb_run "p=.git;a=history;f=non-existent"'
430 test_debug 'cat gitweb.log'
432 test_expect_success \
433 'logs: history (implicit HEAD, deleted file)' \
434 'git checkout master &&
435 echo "to be deleted" > deleted_file &&
436 git add deleted_file &&
437 git commit -m "Add file to be deleted" &&
438 git rm deleted_file &&
439 git commit -m "Delete file" &&
440 gitweb_run "p=.git;a=history;f=deleted_file"'
441 test_debug 'cat gitweb.log'
443 # ----------------------------------------------------------------------
444 # path_info links
445 test_expect_success \
446 'path_info: project' \
447 'gitweb_run "" "/.git"'
448 test_debug 'cat gitweb.log'
450 test_expect_success \
451 'path_info: project/branch' \
452 'gitweb_run "" "/.git/b"'
453 test_debug 'cat gitweb.log'
455 test_expect_success \
456 'path_info: project/branch:file' \
457 'gitweb_run "" "/.git/master:file"'
458 test_debug 'cat gitweb.log'
460 test_expect_success \
461 'path_info: project/branch:dir/' \
462 'gitweb_run "" "/.git/master:foo/"'
463 test_debug 'cat gitweb.log'
465 test_expect_success \
466 'path_info: project/branch:file (non-existent)' \
467 'gitweb_run "" "/.git/master:non-existent"'
468 test_debug 'cat gitweb.log'
470 test_expect_success \
471 'path_info: project/branch:dir/ (non-existent)' \
472 'gitweb_run "" "/.git/master:non-existent/"'
473 test_debug 'cat gitweb.log'
476 test_expect_success \
477 'path_info: project/branch:/file' \
478 'gitweb_run "" "/.git/master:/file"'
479 test_debug 'cat gitweb.log'
481 test_expect_success \
482 'path_info: project/:/file (implicit HEAD)' \
483 'gitweb_run "" "/.git/:/file"'
484 test_debug 'cat gitweb.log'
486 test_expect_success \
487 'path_info: project/:/ (implicit HEAD, top tree)' \
488 'gitweb_run "" "/.git/:/"'
489 test_debug 'cat gitweb.log'
492 # ----------------------------------------------------------------------
493 # feed generation
495 test_expect_success \
496 'feeds: OPML' \
497 'gitweb_run "a=opml"'
498 test_debug 'cat gitweb.log'
500 test_expect_success \
501 'feed: RSS' \
502 'gitweb_run "p=.git;a=rss"'
503 test_debug 'cat gitweb.log'
505 test_expect_success \
506 'feed: Atom' \
507 'gitweb_run "p=.git;a=atom"'
508 test_debug 'cat gitweb.log'
510 # ----------------------------------------------------------------------
511 # encoding/decoding
513 test_expect_success \
514 'encode(commit): utf8' \
515 '. "$TEST_DIRECTORY"/t3901-utf8.txt &&
516 echo "UTF-8" >> file &&
517 git add file &&
518 git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
519 gitweb_run "p=.git;a=commit"'
520 test_debug 'cat gitweb.log'
522 test_expect_success \
523 'encode(commit): iso-8859-1' \
524 '. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
525 echo "ISO-8859-1" >> file &&
526 git add file &&
527 git config i18n.commitencoding ISO-8859-1 &&
528 git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
529 git config --unset i18n.commitencoding &&
530 gitweb_run "p=.git;a=commit"'
531 test_debug 'cat gitweb.log'
533 test_expect_success \
534 'encode(log): utf-8 and iso-8859-1' \
535 'gitweb_run "p=.git;a=log"'
536 test_debug 'cat gitweb.log'
538 # ----------------------------------------------------------------------
539 # extra options
541 test_expect_success \
542 'opt: log --no-merges' \
543 'gitweb_run "p=.git;a=log;opt=--no-merges"'
544 test_debug 'cat gitweb.log'
546 test_expect_success \
547 'opt: atom --no-merges' \
548 'gitweb_run "p=.git;a=log;opt=--no-merges"'
549 test_debug 'cat gitweb.log'
551 test_expect_success \
552 'opt: "file" history --no-merges' \
553 'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
554 test_debug 'cat gitweb.log'
556 test_expect_success \
557 'opt: log --no-such-option (invalid option)' \
558 'gitweb_run "p=.git;a=log;opt=--no-such-option"'
559 test_debug 'cat gitweb.log'
561 test_expect_success \
562 'opt: tree --no-merges (invalid option for action)' \
563 'gitweb_run "p=.git;a=tree;opt=--no-merges"'
564 test_debug 'cat gitweb.log'
566 # ----------------------------------------------------------------------
567 # testing config_to_multi / cloneurl
569 test_expect_success \
570 'URL: no project URLs, no base URL' \
571 'gitweb_run "p=.git;a=summary"'
572 test_debug 'cat gitweb.log'
574 test_expect_success \
575 'URL: project URLs via gitweb.url' \
576 'git config --add gitweb.url git://example.com/git/trash.git &&
577 git config --add gitweb.url http://example.com/git/trash.git &&
578 gitweb_run "p=.git;a=summary"'
579 test_debug 'cat gitweb.log'
581 cat >.git/cloneurl <<\EOF
582 git://example.com/git/trash.git
583 http://example.com/git/trash.git
586 test_expect_success \
587 'URL: project URLs via cloneurl file' \
588 'gitweb_run "p=.git;a=summary"'
589 test_debug 'cat gitweb.log'
591 # ----------------------------------------------------------------------
592 # gitweb config and repo config
594 cat >>gitweb_config.perl <<\EOF
596 # turn on override for each overridable feature
597 foreach my $key (keys %feature) {
598 if ($feature{$key}{'sub'}) {
599 $feature{$key}{'override'} = 1;
604 test_expect_success \
605 'config override: projects list (implicit)' \
606 'gitweb_run'
607 test_debug 'cat gitweb.log'
609 test_expect_success \
610 'config override: tree view, features not overridden in repo config' \
611 'gitweb_run "p=.git;a=tree"'
612 test_debug 'cat gitweb.log'
614 test_expect_success \
615 'config override: tree view, features disabled in repo config' \
616 'git config gitweb.blame no &&
617 git config gitweb.snapshot none &&
618 git config gitweb.avatar gravatar &&
619 gitweb_run "p=.git;a=tree"'
620 test_debug 'cat gitweb.log'
622 test_expect_success \
623 'config override: tree view, features enabled in repo config (1)' \
624 'git config gitweb.blame yes &&
625 git config gitweb.snapshot "zip,tgz, tbz2" &&
626 gitweb_run "p=.git;a=tree"'
627 test_debug 'cat gitweb.log'
629 cat >.git/config <<\EOF
630 # testing noval and alternate separator
631 [gitweb]
632 blame
633 snapshot = zip tgz
635 test_expect_success \
636 'config override: tree view, features enabled in repo config (2)' \
637 'gitweb_run "p=.git;a=tree"'
638 test_debug 'cat gitweb.log'
640 # ----------------------------------------------------------------------
641 # non-ASCII in README.html
643 test_expect_success \
644 'README.html with non-ASCII characters (utf-8)' \
645 'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
646 cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
647 gitweb_run "p=.git;a=summary"'
648 test_debug 'cat gitweb.log'
650 # ----------------------------------------------------------------------
651 # syntax highlighting
654 highlight --version >/dev/null 2>&1
655 if [ $? -eq 127 ]; then
656 say "Skipping syntax highlighting test, because 'highlight' was not found"
657 else
658 test_set_prereq HIGHLIGHT
659 cat >>gitweb_config.perl <<-\EOF
660 our $highlight_bin = "highlight";
661 $feature{'highlight'}{'override'} = 1;
665 test_expect_success HIGHLIGHT \
666 'syntax highlighting (no highlight, unknown syntax)' \
667 'git config gitweb.highlight yes &&
668 gitweb_run "p=.git;a=blob;f=file"'
669 test_debug 'cat gitweb.log'
671 test_expect_success HIGHLIGHT \
672 'syntax highlighting (highlighted, shell script)' \
673 'git config gitweb.highlight yes &&
674 echo "#!/usr/bin/sh" > test.sh &&
675 git add test.sh &&
676 git commit -m "Add test.sh" &&
677 gitweb_run "p=.git;a=blob;f=test.sh"'
678 test_debug 'cat gitweb.log'
680 test_done