Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / git / t / t9500-gitweb-standalone-no-errors.sh
blobd948724566b2185d4934beb1bc82157e893611fc
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 \$home_link_str = "projects";
22 our \$site_name = "[localhost]";
23 our \$site_header = "";
24 our \$site_footer = "";
25 our \$home_text = "indextext.html";
26 our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
27 our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
28 our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
29 our \$projects_list = "";
30 our \$export_ok = "";
31 our \$strict_export = "";
33 CGI::Carp::set_programname("gitweb/gitweb.cgi");
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 . ./test-lib.sh
63 perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
64 test_expect_success 'skipping gitweb tests, perl version is too old' :
65 test_done
66 exit
69 gitweb_init
71 # ----------------------------------------------------------------------
72 # no commits (empty, just initialized repository)
74 test_expect_success \
75 'no commits: projects_list (implicit)' \
76 'gitweb_run'
77 test_debug 'cat gitweb.log'
79 test_expect_success \
80 'no commits: projects_index' \
81 'gitweb_run "a=project_index"'
82 test_debug 'cat gitweb.log'
84 test_expect_success \
85 'no commits: .git summary (implicit)' \
86 'gitweb_run "p=.git"'
87 test_debug 'cat gitweb.log'
89 test_expect_success \
90 'no commits: .git commit (implicit HEAD)' \
91 'gitweb_run "p=.git;a=commit"'
92 test_debug 'cat gitweb.log'
94 test_expect_success \
95 'no commits: .git commitdiff (implicit HEAD)' \
96 'gitweb_run "p=.git;a=commitdiff"'
97 test_debug 'cat gitweb.log'
99 test_expect_success \
100 'no commits: .git tree (implicit HEAD)' \
101 'gitweb_run "p=.git;a=tree"'
102 test_debug 'cat gitweb.log'
104 test_expect_success \
105 'no commits: .git heads' \
106 'gitweb_run "p=.git;a=heads"'
107 test_debug 'cat gitweb.log'
109 test_expect_success \
110 'no commits: .git tags' \
111 'gitweb_run "p=.git;a=tags"'
112 test_debug 'cat gitweb.log'
115 # ----------------------------------------------------------------------
116 # initial commit
118 test_expect_success \
119 'Make initial commit' \
120 'echo "Not an empty file." > file &&
121 git add file &&
122 git commit -a -m "Initial commit." &&
123 git branch b'
125 test_expect_success \
126 'projects_list (implicit)' \
127 'gitweb_run'
128 test_debug 'cat gitweb.log'
130 test_expect_success \
131 'projects_index' \
132 'gitweb_run "a=project_index"'
133 test_debug 'cat gitweb.log'
135 test_expect_success \
136 '.git summary (implicit)' \
137 'gitweb_run "p=.git"'
138 test_debug 'cat gitweb.log'
140 test_expect_success \
141 '.git commit (implicit HEAD)' \
142 'gitweb_run "p=.git;a=commit"'
143 test_debug 'cat gitweb.log'
145 test_expect_success \
146 '.git commitdiff (implicit HEAD, root commit)' \
147 'gitweb_run "p=.git;a=commitdiff"'
148 test_debug 'cat gitweb.log'
150 test_expect_success \
151 '.git commitdiff_plain (implicit HEAD, root commit)' \
152 'gitweb_run "p=.git;a=commitdiff_plain"'
153 test_debug 'cat gitweb.log'
155 test_expect_success \
156 '.git commit (HEAD)' \
157 'gitweb_run "p=.git;a=commit;h=HEAD"'
158 test_debug 'cat gitweb.log'
160 test_expect_success \
161 '.git tree (implicit HEAD)' \
162 'gitweb_run "p=.git;a=tree"'
163 test_debug 'cat gitweb.log'
165 test_expect_success \
166 '.git blob (file)' \
167 'gitweb_run "p=.git;a=blob;f=file"'
168 test_debug 'cat gitweb.log'
170 test_expect_success \
171 '.git blob_plain (file)' \
172 'gitweb_run "p=.git;a=blob_plain;f=file"'
173 test_debug 'cat gitweb.log'
175 # ----------------------------------------------------------------------
176 # nonexistent objects
178 test_expect_success \
179 '.git commit (non-existent)' \
180 'gitweb_run "p=.git;a=commit;h=non-existent"'
181 test_debug 'cat gitweb.log'
183 test_expect_success \
184 '.git commitdiff (non-existent)' \
185 'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
186 test_debug 'cat gitweb.log'
188 test_expect_success \
189 '.git commitdiff (non-existent vs HEAD)' \
190 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
191 test_debug 'cat gitweb.log'
193 test_expect_success \
194 '.git tree (0000000000000000000000000000000000000000)' \
195 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
196 test_debug 'cat gitweb.log'
198 test_expect_success \
199 '.git tag (0000000000000000000000000000000000000000)' \
200 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
201 test_debug 'cat gitweb.log'
203 test_expect_success \
204 '.git blob (non-existent)' \
205 'gitweb_run "p=.git;a=blob;f=non-existent"'
206 test_debug 'cat gitweb.log'
208 test_expect_success \
209 '.git blob_plain (non-existent)' \
210 'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
211 test_debug 'cat gitweb.log'
214 # ----------------------------------------------------------------------
215 # commitdiff testing (implicit, one implicit tree-ish)
217 test_expect_success \
218 'commitdiff(0): root' \
219 'gitweb_run "p=.git;a=commitdiff"'
220 test_debug 'cat gitweb.log'
222 test_expect_success \
223 'commitdiff(0): file added' \
224 'echo "New file" > new_file &&
225 git add new_file &&
226 git commit -a -m "File added." &&
227 gitweb_run "p=.git;a=commitdiff"'
228 test_debug 'cat gitweb.log'
230 test_expect_success \
231 'commitdiff(0): mode change' \
232 'chmod a+x new_file &&
233 git commit -a -m "Mode changed." &&
234 gitweb_run "p=.git;a=commitdiff"'
235 test_debug 'cat gitweb.log'
237 test_expect_success \
238 'commitdiff(0): file renamed' \
239 'git mv new_file renamed_file &&
240 git commit -a -m "File renamed." &&
241 gitweb_run "p=.git;a=commitdiff"'
242 test_debug 'cat gitweb.log'
244 test_expect_success \
245 'commitdiff(0): file to symlink' \
246 'rm renamed_file &&
247 ln -s file renamed_file &&
248 git commit -a -m "File to symlink." &&
249 gitweb_run "p=.git;a=commitdiff"'
250 test_debug 'cat gitweb.log'
252 test_expect_success \
253 'commitdiff(0): file deleted' \
254 'git rm renamed_file &&
255 rm -f renamed_file &&
256 git commit -a -m "File removed." &&
257 gitweb_run "p=.git;a=commitdiff"'
258 test_debug 'cat gitweb.log'
260 test_expect_success \
261 'commitdiff(0): file copied / new file' \
262 'cp file file2 &&
263 git add file2 &&
264 git commit -a -m "File copied." &&
265 gitweb_run "p=.git;a=commitdiff"'
266 test_debug 'cat gitweb.log'
268 test_expect_success \
269 'commitdiff(0): mode change and modified' \
270 'echo "New line" >> file2 &&
271 chmod a+x file2 &&
272 git commit -a -m "Mode change and modification." &&
273 gitweb_run "p=.git;a=commitdiff"'
274 test_debug 'cat gitweb.log'
276 test_expect_success \
277 'commitdiff(0): renamed and modified' \
278 'cat >file2<<EOF &&
279 Dominus regit me,
280 et nihil mihi deerit.
281 In loco pascuae ibi me collocavit,
282 super aquam refectionis educavit me;
283 animam meam convertit,
284 deduxit me super semitas jusitiae,
285 propter nomen suum.
287 git commit -a -m "File added." &&
288 git mv file2 file3 &&
289 echo "Propter nomen suum." >> file3 &&
290 git commit -a -m "File rename and modification." &&
291 gitweb_run "p=.git;a=commitdiff"'
292 test_debug 'cat gitweb.log'
294 test_expect_success \
295 'commitdiff(0): renamed, mode change and modified' \
296 'git mv file3 file2 &&
297 echo "Propter nomen suum." >> file2 &&
298 chmod a+x file2 &&
299 git commit -a -m "File rename, mode change and modification." &&
300 gitweb_run "p=.git;a=commitdiff"'
301 test_debug 'cat gitweb.log'
303 # ----------------------------------------------------------------------
304 # commitdiff testing (taken from t4114-apply-typechange.sh)
306 test_expect_success 'setup typechange commits' '
307 echo "hello world" > foo &&
308 echo "hi planet" > bar &&
309 git update-index --add foo bar &&
310 git commit -m initial &&
311 git branch initial &&
312 rm -f foo &&
313 ln -s bar foo &&
314 git update-index foo &&
315 git commit -m "foo symlinked to bar" &&
316 git branch foo-symlinked-to-bar &&
317 rm -f foo &&
318 echo "how far is the sun?" > foo &&
319 git update-index foo &&
320 git commit -m "foo back to file" &&
321 git branch foo-back-to-file &&
322 rm -f foo &&
323 git update-index --remove foo &&
324 mkdir foo &&
325 echo "if only I knew" > foo/baz &&
326 git update-index --add foo/baz &&
327 git commit -m "foo becomes a directory" &&
328 git branch "foo-becomes-a-directory" &&
329 echo "hello world" > foo/baz &&
330 git update-index foo/baz &&
331 git commit -m "foo/baz is the original foo" &&
332 git branch foo-baz-renamed-from-foo
335 test_expect_success \
336 'commitdiff(2): file renamed from foo to foo/baz' \
337 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
338 test_debug 'cat gitweb.log'
340 test_expect_success \
341 'commitdiff(2): file renamed from foo/baz to foo' \
342 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
343 test_debug 'cat gitweb.log'
345 test_expect_success \
346 'commitdiff(2): directory becomes file' \
347 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
348 test_debug 'cat gitweb.log'
350 test_expect_success \
351 'commitdiff(2): file becomes directory' \
352 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
353 test_debug 'cat gitweb.log'
355 test_expect_success \
356 'commitdiff(2): file becomes symlink' \
357 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
358 test_debug 'cat gitweb.log'
360 test_expect_success \
361 'commitdiff(2): symlink becomes file' \
362 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
363 test_debug 'cat gitweb.log'
365 test_expect_success \
366 'commitdiff(2): symlink becomes directory' \
367 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
368 test_debug 'cat gitweb.log'
370 test_expect_success \
371 'commitdiff(2): directory becomes symlink' \
372 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
373 test_debug 'cat gitweb.log'
375 # ----------------------------------------------------------------------
376 # commit, commitdiff: merge, large
377 test_expect_success \
378 'Create a merge' \
379 'git checkout b &&
380 echo "Branch" >> b &&
381 git add b &&
382 git commit -a -m "On branch" &&
383 git checkout master &&
384 git pull . b'
386 test_expect_success \
387 'commit(0): merge commit' \
388 'gitweb_run "p=.git;a=commit"'
389 test_debug 'cat gitweb.log'
391 test_expect_success \
392 'commitdiff(0): merge commit' \
393 'gitweb_run "p=.git;a=commitdiff"'
394 test_debug 'cat gitweb.log'
396 test_expect_success \
397 'Prepare large commit' \
398 'git checkout b &&
399 echo "To be changed" > 01-change &&
400 echo "To be renamed" > 02-pure-rename-from &&
401 echo "To be deleted" > 03-delete &&
402 echo "To be renamed and changed" > 04-rename-from &&
403 echo "To have mode changed" > 05-mode-change &&
404 echo "File to symlink" > 06-file-or-symlink &&
405 echo "To be changed and have mode changed" > 07-change-mode-change &&
406 git add 0* &&
407 git commit -a -m "Prepare large commit" &&
408 echo "Changed" > 01-change &&
409 git mv 02-pure-rename-from 02-pure-rename-to &&
410 git rm 03-delete && rm -f 03-delete &&
411 echo "A new file" > 03-new &&
412 git add 03-new &&
413 git mv 04-rename-from 04-rename-to &&
414 echo "Changed" >> 04-rename-to &&
415 chmod a+x 05-mode-change &&
416 rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
417 echo "Changed and have mode changed" > 07-change-mode-change &&
418 chmod a+x 07-change-mode-change &&
419 git commit -a -m "Large commit" &&
420 git checkout master'
422 test_expect_success \
423 'commit(1): large commit' \
424 'gitweb_run "p=.git;a=commit;h=b"'
425 test_debug 'cat gitweb.log'
427 test_expect_success \
428 'commitdiff(1): large commit' \
429 'gitweb_run "p=.git;a=commitdiff;h=b"'
430 test_debug 'cat gitweb.log'
432 # ----------------------------------------------------------------------
433 # tags testing
435 test_expect_success \
436 'tags: list of different types of tags' \
437 'git checkout master &&
438 git tag -a -m "Tag commit object" tag-commit HEAD &&
439 git tag -a -m "" tag-commit-nomessage HEAD &&
440 git tag -a -m "Tag tag object" tag-tag tag-commit &&
441 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
442 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
443 git tag lightweight/tag-commit HEAD &&
444 git tag lightweight/tag-tag tag-commit &&
445 git tag lightweight/tag-tree HEAD^{tree} &&
446 git tag lightweight/tag-blob HEAD:file &&
447 gitweb_run "p=.git;a=tags"'
448 test_debug 'cat gitweb.log'
450 test_expect_success \
451 'tag: Tag to commit object' \
452 'gitweb_run "p=.git;a=tag;h=tag-commit"'
453 test_debug 'cat gitweb.log'
455 test_expect_success \
456 'tag: on lightweight tag (invalid)' \
457 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
458 test_debug 'cat gitweb.log'
460 # ----------------------------------------------------------------------
461 # logs
463 test_expect_success \
464 'logs: log (implicit HEAD)' \
465 'gitweb_run "p=.git;a=log"'
466 test_debug 'cat gitweb.log'
468 test_expect_success \
469 'logs: shortlog (implicit HEAD)' \
470 'gitweb_run "p=.git;a=shortlog"'
471 test_debug 'cat gitweb.log'
473 test_expect_success \
474 'logs: history (implicit HEAD, file)' \
475 'gitweb_run "p=.git;a=history;f=file"'
476 test_debug 'cat gitweb.log'
478 # ----------------------------------------------------------------------
479 # feed generation
481 test_expect_success \
482 'feeds: OPML' \
483 'gitweb_run "a=opml"'
484 test_debug 'cat gitweb.log'
486 test_expect_success \
487 'feed: RSS' \
488 'gitweb_run "p=.git;a=rss"'
489 test_debug 'cat gitweb.log'
491 test_expect_success \
492 'feed: Atom' \
493 'gitweb_run "p=.git;a=atom"'
494 test_debug 'cat gitweb.log'
496 # ----------------------------------------------------------------------
497 # encoding/decoding
499 test_expect_success \
500 'encode(commit): utf8' \
501 '. ../t3901-utf8.txt &&
502 echo "UTF-8" >> file &&
503 git add file &&
504 git commit -F ../t3900/1-UTF-8.txt &&
505 gitweb_run "p=.git;a=commit"'
506 test_debug 'cat gitweb.log'
508 test_expect_success \
509 'encode(commit): iso-8859-1' \
510 '. ../t3901-8859-1.txt &&
511 echo "ISO-8859-1" >> file &&
512 git add file &&
513 git config i18n.commitencoding ISO-8859-1 &&
514 git commit -F ../t3900/ISO-8859-1.txt &&
515 git config --unset i18n.commitencoding &&
516 gitweb_run "p=.git;a=commit"'
517 test_debug 'cat gitweb.log'
519 test_expect_success \
520 'encode(log): utf-8 and iso-8859-1' \
521 'gitweb_run "p=.git;a=log"'
522 test_debug 'cat gitweb.log'
524 test_done