setup: merge configuration of repository formats
[git/gitster.git] / t / t9500-gitweb-standalone-no-errors.sh
blobccfa4153840acfdcf9e2002baa1bcf90a7ccd0a5
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 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
14 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
16 TEST_PASSES_SANITIZE_LEAK=true
17 . ./lib-gitweb.sh
19 # ----------------------------------------------------------------------
20 # no commits (empty, just initialized repository)
22 test_expect_success \
23 'no commits: projects_list (implicit)' \
24 'gitweb_run'
26 test_expect_success \
27 'no commits: projects_index' \
28 'gitweb_run "a=project_index"'
30 test_expect_success \
31 'no commits: .git summary (implicit)' \
32 'gitweb_run "p=.git"'
34 test_expect_success \
35 'no commits: .git commit (implicit HEAD)' \
36 'gitweb_run "p=.git;a=commit"'
38 test_expect_success \
39 'no commits: .git commitdiff (implicit HEAD)' \
40 'gitweb_run "p=.git;a=commitdiff"'
42 test_expect_success \
43 'no commits: .git tree (implicit HEAD)' \
44 'gitweb_run "p=.git;a=tree"'
46 test_expect_success \
47 'no commits: .git heads' \
48 'gitweb_run "p=.git;a=heads"'
50 test_expect_success \
51 'no commits: .git tags' \
52 'gitweb_run "p=.git;a=tags"'
55 # ----------------------------------------------------------------------
56 # initial commit
58 test_expect_success \
59 'Make initial commit' \
60 'echo "Not an empty file." >file &&
61 git add file &&
62 git commit -a -m "Initial commit." &&
63 git branch b'
65 test_expect_success \
66 'projects_list (implicit)' \
67 'gitweb_run'
69 test_expect_success \
70 'projects_index' \
71 'gitweb_run "a=project_index"'
73 test_expect_success \
74 '.git summary (implicit)' \
75 'gitweb_run "p=.git"'
77 test_expect_success \
78 '.git commit (implicit HEAD)' \
79 'gitweb_run "p=.git;a=commit"'
81 test_expect_success \
82 '.git commitdiff (implicit HEAD, root commit)' \
83 'gitweb_run "p=.git;a=commitdiff"'
85 test_expect_success \
86 '.git commitdiff_plain (implicit HEAD, root commit)' \
87 'gitweb_run "p=.git;a=commitdiff_plain"'
89 test_expect_success \
90 '.git commit (HEAD)' \
91 'gitweb_run "p=.git;a=commit;h=HEAD"'
93 test_expect_success \
94 '.git tree (implicit HEAD)' \
95 'gitweb_run "p=.git;a=tree"'
97 test_expect_success \
98 '.git blob (file)' \
99 'gitweb_run "p=.git;a=blob;f=file"'
101 test_expect_success \
102 '.git blob_plain (file)' \
103 'gitweb_run "p=.git;a=blob_plain;f=file"'
105 # ----------------------------------------------------------------------
106 # nonexistent objects
108 test_expect_success \
109 '.git commit (non-existent)' \
110 'gitweb_run "p=.git;a=commit;h=non-existent"'
112 test_expect_success \
113 '.git commitdiff (non-existent)' \
114 'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
116 test_expect_success \
117 '.git commitdiff (non-existent vs HEAD)' \
118 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
120 test_expect_success \
121 '.git tree (0000000000000000000000000000000000000000)' \
122 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
124 test_expect_success \
125 '.git tag (0000000000000000000000000000000000000000)' \
126 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
128 test_expect_success \
129 '.git blob (non-existent)' \
130 'gitweb_run "p=.git;a=blob;f=non-existent"'
132 test_expect_success \
133 '.git blob_plain (non-existent)' \
134 'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
137 # ----------------------------------------------------------------------
138 # commitdiff testing (implicit, one implicit tree-ish)
140 test_expect_success \
141 'commitdiff(0): root' \
142 'gitweb_run "p=.git;a=commitdiff"'
144 test_expect_success \
145 'commitdiff(0): file added' \
146 'echo "New file" >new_file &&
147 git add new_file &&
148 git commit -a -m "File added." &&
149 gitweb_run "p=.git;a=commitdiff"'
151 test_expect_success \
152 'commitdiff(0): mode change' \
153 'test_chmod +x new_file &&
154 git commit -a -m "Mode changed." &&
155 gitweb_run "p=.git;a=commitdiff"'
157 test_expect_success \
158 'commitdiff(0): file renamed' \
159 'git mv new_file renamed_file &&
160 git commit -a -m "File renamed." &&
161 gitweb_run "p=.git;a=commitdiff"'
163 test_expect_success \
164 'commitdiff(0): file to symlink' \
165 'rm renamed_file &&
166 test_ln_s_add file renamed_file &&
167 git commit -a -m "File to symlink." &&
168 gitweb_run "p=.git;a=commitdiff"'
170 test_expect_success \
171 'commitdiff(0): file deleted' \
172 'git rm renamed_file &&
173 rm -f renamed_file &&
174 git commit -a -m "File removed." &&
175 gitweb_run "p=.git;a=commitdiff"'
177 test_expect_success \
178 'commitdiff(0): file copied / new file' \
179 'cp file file2 &&
180 git add file2 &&
181 git commit -a -m "File copied." &&
182 gitweb_run "p=.git;a=commitdiff"'
184 test_expect_success \
185 'commitdiff(0): mode change and modified' \
186 'echo "New line" >>file2 &&
187 test_chmod +x file2 &&
188 git commit -a -m "Mode change and modification." &&
189 gitweb_run "p=.git;a=commitdiff"'
191 test_expect_success \
192 'commitdiff(0): renamed and modified' \
193 'cat >file2<<EOF &&
194 Dominus regit me,
195 et nihil mihi deerit.
196 In loco pascuae ibi me collocavit,
197 super aquam refectionis educavit me;
198 animam meam convertit,
199 deduxit me super semitas jusitiae,
200 propter nomen suum.
202 git commit -a -m "File added." &&
203 git mv file2 file3 &&
204 echo "Propter nomen suum." >>file3 &&
205 git commit -a -m "File rename and modification." &&
206 gitweb_run "p=.git;a=commitdiff"'
208 test_expect_success \
209 'commitdiff(0): renamed, mode change and modified' \
210 'git mv file3 file2 &&
211 echo "Propter nomen suum." >>file2 &&
212 test_chmod +x file2 &&
213 git commit -a -m "File rename, mode change and modification." &&
214 gitweb_run "p=.git;a=commitdiff"'
216 # ----------------------------------------------------------------------
217 # commitdiff testing (taken from t4114-apply-typechange.sh)
219 test_expect_success 'setup typechange commits' '
220 echo "hello world" >foo &&
221 echo "hi planet" >bar &&
222 git update-index --add foo bar &&
223 git commit -m initial &&
224 git branch initial &&
225 rm -f foo &&
226 test_ln_s_add bar foo &&
227 git commit -m "foo symlinked to bar" &&
228 git branch foo-symlinked-to-bar &&
229 rm -f foo &&
230 echo "how far is the sun?" >foo &&
231 git update-index foo &&
232 git commit -m "foo back to file" &&
233 git branch foo-back-to-file &&
234 rm -f foo &&
235 git update-index --remove foo &&
236 mkdir foo &&
237 echo "if only I knew" >foo/baz &&
238 git update-index --add foo/baz &&
239 git commit -m "foo becomes a directory" &&
240 git branch "foo-becomes-a-directory" &&
241 echo "hello world" >foo/baz &&
242 git update-index foo/baz &&
243 git commit -m "foo/baz is the original foo" &&
244 git branch foo-baz-renamed-from-foo
247 test_expect_success \
248 'commitdiff(2): file renamed from foo to foo/baz' \
249 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
251 test_expect_success \
252 'commitdiff(2): file renamed from foo/baz to foo' \
253 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
255 test_expect_success \
256 'commitdiff(2): directory becomes file' \
257 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
259 test_expect_success \
260 'commitdiff(2): file becomes directory' \
261 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
263 test_expect_success \
264 'commitdiff(2): file becomes symlink' \
265 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
267 test_expect_success \
268 'commitdiff(2): symlink becomes file' \
269 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
271 test_expect_success \
272 'commitdiff(2): symlink becomes directory' \
273 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
275 test_expect_success \
276 'commitdiff(2): directory becomes symlink' \
277 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
279 # ----------------------------------------------------------------------
280 # commitdiff testing (incomplete lines)
282 test_expect_success 'setup incomplete lines' '
283 cat >file<<-\EOF &&
284 Dominus regit me,
285 et nihil mihi deerit.
286 In loco pascuae ibi me collocavit,
287 super aquam refectionis educavit me;
288 animam meam convertit,
289 deduxit me super semitas jusitiae,
290 propter nomen suum.
291 CHANGE_ME
293 git commit -a -m "Preparing for incomplete lines" &&
294 echo "incomplete" | tr -d "\\012" >>file &&
295 git commit -a -m "Add incomplete line" &&
296 git tag incomplete_lines_add &&
297 sed -e s/CHANGE_ME/change_me/ <file >file+ &&
298 mv -f file+ file &&
299 git commit -a -m "Incomplete context line" &&
300 git tag incomplete_lines_ctx &&
301 echo "Dominus regit me," >file &&
302 echo "incomplete line" | tr -d "\\012" >>file &&
303 git commit -a -m "Change incomplete line" &&
304 git tag incomplete_lines_chg &&
305 echo "Dominus regit me," >file &&
306 git commit -a -m "Remove incomplete line" &&
307 git tag incomplete_lines_rem
310 test_expect_success 'commitdiff(1): addition of incomplete line' '
311 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add"
314 test_expect_success 'commitdiff(1): incomplete line as context line' '
315 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx"
318 test_expect_success 'commitdiff(1): change incomplete line' '
319 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg"
322 test_expect_success 'commitdiff(1): removal of incomplete line' '
323 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem"
326 # ----------------------------------------------------------------------
327 # commit, commitdiff: merge, large
328 test_expect_success \
329 'Create a merge' \
330 'git checkout b &&
331 echo "Branch" >>b &&
332 git add b &&
333 git commit -a -m "On branch" &&
334 git checkout main &&
335 git merge b &&
336 git tag merge_commit'
338 test_expect_success \
339 'commit(0): merge commit' \
340 'gitweb_run "p=.git;a=commit"'
342 test_expect_success \
343 'commitdiff(0): merge commit' \
344 'gitweb_run "p=.git;a=commitdiff"'
346 test_expect_success \
347 'Prepare large commit' \
348 'git checkout b &&
349 echo "To be changed" >01-change &&
350 echo "To be renamed" >02-pure-rename-from &&
351 echo "To be deleted" >03-delete &&
352 echo "To be renamed and changed" >04-rename-from &&
353 echo "To have mode changed" >05-mode-change &&
354 echo "File to symlink" >06-file-or-symlink &&
355 echo "To be changed and have mode changed" >07-change-mode-change &&
356 git add 0* &&
357 git commit -a -m "Prepare large commit" &&
358 echo "Changed" >01-change &&
359 git mv 02-pure-rename-from 02-pure-rename-to &&
360 git rm 03-delete && rm -f 03-delete &&
361 echo "A new file" >03-new &&
362 git add 03-new &&
363 git mv 04-rename-from 04-rename-to &&
364 echo "Changed" >>04-rename-to &&
365 test_chmod +x 05-mode-change &&
366 rm -f 06-file-or-symlink &&
367 test_ln_s_add 01-change 06-file-or-symlink &&
368 echo "Changed and have mode changed" >07-change-mode-change &&
369 test_chmod +x 07-change-mode-change &&
370 git commit -a -m "Large commit" &&
371 git checkout main'
373 test_expect_success \
374 'commit(1): large commit' \
375 'gitweb_run "p=.git;a=commit;h=b"'
377 test_expect_success \
378 'commitdiff(1): large commit' \
379 'gitweb_run "p=.git;a=commitdiff;h=b"'
381 # ----------------------------------------------------------------------
382 # side-by-side diff
384 test_expect_success 'side-by-side: addition of incomplete line' '
385 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add;ds=sidebyside"
388 test_expect_success 'side-by-side: incomplete line as context line' '
389 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx;ds=sidebyside"
392 test_expect_success 'side-by-side: changed incomplete line' '
393 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg;ds=sidebyside"
396 test_expect_success 'side-by-side: removal of incomplete line' '
397 gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem;ds=sidebyside"
400 test_expect_success 'side-by-side: merge commit' '
401 gitweb_run "p=.git;a=commitdiff;h=merge_commit;ds=sidebyside"
404 # ----------------------------------------------------------------------
405 # tags testing
407 test_expect_success \
408 'tags: list of different types of tags' \
409 'git checkout main &&
410 git tag -a -m "Tag commit object" tag-commit HEAD &&
411 git tag -a -m "" tag-commit-nomessage HEAD &&
412 git tag -a -m "Tag tag object" tag-tag tag-commit &&
413 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
414 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
415 git tag lightweight/tag-commit HEAD &&
416 git tag lightweight/tag-tag tag-commit &&
417 git tag lightweight/tag-tree HEAD^{tree} &&
418 git tag lightweight/tag-blob HEAD:file &&
419 gitweb_run "p=.git;a=tags"'
421 test_expect_success \
422 'tag: Tag to commit object' \
423 'gitweb_run "p=.git;a=tag;h=tag-commit"'
425 test_expect_success \
426 'tag: on lightweight tag (invalid)' \
427 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
429 # ----------------------------------------------------------------------
430 # logs
432 test_expect_success \
433 'logs: log (implicit HEAD)' \
434 'gitweb_run "p=.git;a=log"'
436 test_expect_success \
437 'logs: shortlog (implicit HEAD)' \
438 'gitweb_run "p=.git;a=shortlog"'
440 test_expect_success \
441 'logs: history (implicit HEAD, file)' \
442 'gitweb_run "p=.git;a=history;f=file"'
444 test_expect_success \
445 'logs: history (implicit HEAD, non-existent file)' \
446 'gitweb_run "p=.git;a=history;f=non-existent"'
448 test_expect_success \
449 'logs: history (implicit HEAD, deleted file)' \
450 'git checkout main &&
451 echo "to be deleted" >deleted_file &&
452 git add deleted_file &&
453 git commit -m "Add file to be deleted" &&
454 git rm deleted_file &&
455 git commit -m "Delete file" &&
456 gitweb_run "p=.git;a=history;f=deleted_file"'
458 # ----------------------------------------------------------------------
459 # path_info links
460 test_expect_success \
461 'path_info: project' \
462 'gitweb_run "" "/.git"'
464 test_expect_success \
465 'path_info: project/branch' \
466 'gitweb_run "" "/.git/b"'
468 test_expect_success \
469 'path_info: project/branch:file' \
470 'gitweb_run "" "/.git/main:file"'
472 test_expect_success \
473 'path_info: project/branch:dir/' \
474 'gitweb_run "" "/.git/main:foo/"'
476 test_expect_success \
477 'path_info: project/branch (non-existent)' \
478 'gitweb_run "" "/.git/non-existent"'
480 test_expect_success \
481 'path_info: project/branch:filename (non-existent branch)' \
482 'gitweb_run "" "/.git/non-existent:non-existent"'
484 test_expect_success \
485 'path_info: project/branch:file (non-existent)' \
486 'gitweb_run "" "/.git/main:non-existent"'
488 test_expect_success \
489 'path_info: project/branch:dir/ (non-existent)' \
490 'gitweb_run "" "/.git/main:non-existent/"'
493 test_expect_success \
494 'path_info: project/branch:/file' \
495 'gitweb_run "" "/.git/main:/file"'
497 test_expect_success \
498 'path_info: project/:/file (implicit HEAD)' \
499 'gitweb_run "" "/.git/:/file"'
501 test_expect_success \
502 'path_info: project/:/ (implicit HEAD, top tree)' \
503 'gitweb_run "" "/.git/:/"'
506 # ----------------------------------------------------------------------
507 # feed generation
509 test_expect_success \
510 'feeds: OPML' \
511 'gitweb_run "a=opml"'
513 test_expect_success \
514 'feed: RSS' \
515 'gitweb_run "p=.git;a=rss"'
517 test_expect_success \
518 'feed: Atom' \
519 'gitweb_run "p=.git;a=atom"'
521 # ----------------------------------------------------------------------
522 # encoding/decoding
524 test_expect_success \
525 'encode(commit): utf8' \
526 '. "$TEST_DIRECTORY"/t3901/utf8.txt &&
527 test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
528 test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
529 echo "UTF-8" >>file &&
530 git add file &&
531 git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
532 gitweb_run "p=.git;a=commit"'
534 test_expect_success \
535 'encode(commit): iso-8859-1' \
536 '. "$TEST_DIRECTORY"/t3901/8859-1.txt &&
537 test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
538 test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
539 echo "ISO-8859-1" >>file &&
540 git add file &&
541 test_config i18n.commitencoding ISO-8859-1 &&
542 git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
543 gitweb_run "p=.git;a=commit"'
545 test_expect_success \
546 'encode(log): utf-8 and iso-8859-1' \
547 'gitweb_run "p=.git;a=log"'
549 # ----------------------------------------------------------------------
550 # extra options
552 test_expect_success \
553 'opt: log --no-merges' \
554 'gitweb_run "p=.git;a=log;opt=--no-merges"'
556 test_expect_success \
557 'opt: atom --no-merges' \
558 'gitweb_run "p=.git;a=log;opt=--no-merges"'
560 test_expect_success \
561 'opt: "file" history --no-merges' \
562 'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
564 test_expect_success \
565 'opt: log --no-such-option (invalid option)' \
566 'gitweb_run "p=.git;a=log;opt=--no-such-option"'
568 test_expect_success \
569 'opt: tree --no-merges (invalid option for action)' \
570 'gitweb_run "p=.git;a=tree;opt=--no-merges"'
572 # ----------------------------------------------------------------------
573 # testing config_to_multi / cloneurl
575 test_expect_success \
576 'URL: no project URLs, no base URL' \
577 'gitweb_run "p=.git;a=summary"'
579 test_expect_success \
580 'URL: project URLs via gitweb.url' \
581 'git config --add gitweb.url git://example.com/git/trash.git &&
582 git config --add gitweb.url http://example.com/git/trash.git &&
583 gitweb_run "p=.git;a=summary"'
585 cat >.git/cloneurl <<\EOF
586 git://example.com/git/trash.git
587 http://example.com/git/trash.git
590 test_expect_success \
591 'URL: project URLs via cloneurl file' \
592 'gitweb_run "p=.git;a=summary"'
594 # ----------------------------------------------------------------------
595 # gitweb config and repo config
597 cat >>gitweb_config.perl <<\EOF
599 # turn on override for each overridable feature
600 foreach my $key (keys %feature) {
601 if ($feature{$key}{'sub'}) {
602 $feature{$key}{'override'} = 1;
607 test_expect_success \
608 'config override: projects list (implicit)' \
609 'gitweb_run'
611 test_expect_success \
612 'config override: tree view, features not overridden in repo config' \
613 'gitweb_run "p=.git;a=tree"'
615 test_expect_success \
616 'config override: tree view, features disabled in repo config' \
617 'git config gitweb.blame no &&
618 git config gitweb.snapshot none &&
619 git config gitweb.avatar gravatar &&
620 gitweb_run "p=.git;a=tree"'
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"'
628 test_expect_success 'setup' '
629 version=$(git config core.repositoryformatversion) &&
630 algo=$(test_might_fail git config extensions.objectformat) &&
631 refstorage=$(test_might_fail git config extensions.refstorage) &&
632 cat >.git/config <<-\EOF &&
633 # testing noval and alternate separator
634 [gitweb]
635 blame
636 snapshot = zip tgz
638 git config core.repositoryformatversion "$version" &&
639 if test -n "$algo"
640 then
641 git config extensions.objectformat "$algo"
642 fi &&
643 if test -n "$refstorage"
644 then
645 git config extensions.refstorage "$refstorage"
649 test_expect_success \
650 'config override: tree view, features enabled in repo config (2)' \
651 'gitweb_run "p=.git;a=tree"'
653 # ----------------------------------------------------------------------
654 # searching
656 cat >>gitweb_config.perl <<\EOF
658 # enable search
659 $feature{'search'}{'default'} = [1];
660 $feature{'grep'}{'default'} = [1];
661 $feature{'pickaxe'}{'default'} = [1];
664 test_expect_success \
665 'search: preparation' \
666 'echo "1st MATCH" >>file &&
667 echo "2nd MATCH" >>file &&
668 echo "MATCH" >>bar &&
669 git add file bar &&
670 git commit -m "Added MATCH word"'
672 test_expect_success \
673 'search: commit author' \
674 'gitweb_run "p=.git;a=search;h=HEAD;st=author;s=A+U+Thor"'
676 test_expect_success \
677 'search: commit message' \
678 'gitweb_run "p=.git;a=search;h=HEAD;st=commitr;s=MATCH"'
680 test_expect_success \
681 'search: grep' \
682 'gitweb_run "p=.git;a=search;h=HEAD;st=grep;s=MATCH"'
684 test_expect_success \
685 'search: pickaxe' \
686 'gitweb_run "p=.git;a=search;h=HEAD;st=pickaxe;s=MATCH"'
688 test_expect_success \
689 'search: projects' \
690 'gitweb_run "a=project_list;s=.git"'
692 # ----------------------------------------------------------------------
693 # non-ASCII in README.html
695 test_expect_success \
696 'README.html with non-ASCII characters (utf-8)' \
697 'echo "<b>UTF-8 example:</b><br />" >.git/README.html &&
698 cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >>.git/README.html &&
699 gitweb_run "p=.git;a=summary"'
701 # ----------------------------------------------------------------------
702 # syntax highlighting
705 highlight_version=$(highlight --version </dev/null 2>/dev/null)
706 if [ $? -eq 127 ]; then
707 say "Skipping syntax highlighting tests: 'highlight' not found"
708 elif test -z "$highlight_version"; then
709 say "Skipping syntax highlighting tests: incorrect 'highlight' found"
710 else
711 test_set_prereq HIGHLIGHT
712 cat >>gitweb_config.perl <<-\EOF
713 our $highlight_bin = "highlight";
714 $feature{'highlight'}{'override'} = 1;
718 test_expect_success HIGHLIGHT \
719 'syntax highlighting (no highlight, unknown syntax)' \
720 'git config gitweb.highlight yes &&
721 gitweb_run "p=.git;a=blob;f=file"'
723 test_expect_success HIGHLIGHT \
724 'syntax highlighting (highlighted, shell script)' \
725 'git config gitweb.highlight yes &&
726 echo "#!/usr/bin/sh" >test.sh &&
727 git add test.sh &&
728 git commit -m "Add test.sh" &&
729 gitweb_run "p=.git;a=blob;f=test.sh"'
731 test_expect_success HIGHLIGHT \
732 'syntax highlighting (highlighter language autodetection)' \
733 'git config gitweb.highlight yes &&
734 echo "#!/usr/bin/perl" >test &&
735 git add test &&
736 git commit -m "Add test" &&
737 gitweb_run "p=.git;a=blob;f=test"'
739 # ----------------------------------------------------------------------
740 # forks of projects
742 cat >>gitweb_config.perl <<\EOF &&
743 $feature{'forks'}{'default'} = [1];
746 test_expect_success \
747 'forks: prepare' \
748 'git init --bare foo.git &&
749 git --git-dir=foo.git --work-tree=. add file &&
750 git --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&
751 echo "foo" >foo.git/description &&
752 mkdir -p foo &&
753 (cd foo &&
754 git clone --shared --bare ../foo.git foo-forked.git &&
755 echo "fork of foo" >foo-forked.git/description)'
757 test_expect_success \
758 'forks: projects list' \
759 'gitweb_run'
761 test_expect_success \
762 'forks: forks action' \
763 'gitweb_run "p=foo.git;a=forks"'
765 # ----------------------------------------------------------------------
766 # content tags (tag cloud)
768 cat >>gitweb_config.perl <<-\EOF &&
769 # we don't test _setting_ content tags, so any true value is good
770 $feature{'ctags'}{'default'} = ['ctags_script.cgi'];
773 test_expect_success \
774 'ctags: tag cloud in projects list' \
775 'mkdir .git/ctags &&
776 echo "2" >.git/ctags/foo &&
777 echo "1" >.git/ctags/bar &&
778 gitweb_run'
780 test_expect_success \
781 'ctags: search projects by existing tag' \
782 'gitweb_run "by_tag=foo"'
784 test_expect_success \
785 'ctags: search projects by non existent tag' \
786 'gitweb_run "by_tag=non-existent"'
788 test_expect_success \
789 'ctags: malformed tag weights' \
790 'mkdir -p .git/ctags &&
791 echo "not-a-number" >.git/ctags/nan &&
792 echo "not-a-number-2" >.git/ctags/nan2 &&
793 echo "0.1" >.git/ctags/floating-point &&
794 gitweb_run'
796 # ----------------------------------------------------------------------
797 # categories
799 test_expect_success \
800 'categories: projects list, only default category' \
801 'echo "\$projects_list_group_categories = 1;" >>gitweb_config.perl &&
802 gitweb_run'
804 # ----------------------------------------------------------------------
805 # unborn branches
807 test_expect_success \
808 'unborn HEAD: "summary" page (with "heads" subview)' \
810 git checkout orphan_branch ||
811 git checkout --orphan orphan_branch
812 } &&
813 test_when_finished "git checkout main" &&
814 gitweb_run "p=.git;a=summary"'
816 test_done