git-svn: reduce stat() calls for a backwards compatibility check
[git/dscho.git] / t / t9500-gitweb-standalone-no-errors.sh
blob44ae503b992ee26023a19830039062e01be9aa57
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 gitweb_init
65 # ----------------------------------------------------------------------
66 # no commits (empty, just initialized repository)
68 test_expect_success \
69 'no commits: projects_list (implicit)' \
70 'gitweb_run'
71 test_debug 'cat gitweb.log'
73 test_expect_success \
74 'no commits: projects_index' \
75 'gitweb_run "a=project_index"'
76 test_debug 'cat gitweb.log'
78 test_expect_success \
79 'no commits: .git summary (implicit)' \
80 'gitweb_run "p=.git"'
81 test_debug 'cat gitweb.log'
83 test_expect_success \
84 'no commits: .git commit (implicit HEAD)' \
85 'gitweb_run "p=.git;a=commit"'
86 test_debug 'cat gitweb.log'
88 test_expect_success \
89 'no commits: .git commitdiff (implicit HEAD)' \
90 'gitweb_run "p=.git;a=commitdiff"'
91 test_debug 'cat gitweb.log'
93 test_expect_success \
94 'no commits: .git tree (implicit HEAD)' \
95 'gitweb_run "p=.git;a=tree"'
96 test_debug 'cat gitweb.log'
98 test_expect_success \
99 'no commits: .git heads' \
100 'gitweb_run "p=.git;a=heads"'
101 test_debug 'cat gitweb.log'
103 test_expect_success \
104 'no commits: .git tags' \
105 'gitweb_run "p=.git;a=tags"'
106 test_debug 'cat gitweb.log'
109 # ----------------------------------------------------------------------
110 # initial commit
112 test_expect_success \
113 'Make initial commit' \
114 'echo "Not an empty file." > file &&
115 git add file &&
116 git commit -a -m "Initial commit." &&
117 git branch b'
119 test_expect_success \
120 'projects_list (implicit)' \
121 'gitweb_run'
122 test_debug 'cat gitweb.log'
124 test_expect_success \
125 'projects_index' \
126 'gitweb_run "a=project_index"'
127 test_debug 'cat gitweb.log'
129 test_expect_success \
130 '.git summary (implicit)' \
131 'gitweb_run "p=.git"'
132 test_debug 'cat gitweb.log'
134 test_expect_success \
135 '.git commit (implicit HEAD)' \
136 'gitweb_run "p=.git;a=commit"'
137 test_debug 'cat gitweb.log'
139 test_expect_success \
140 '.git commitdiff (implicit HEAD, root commit)' \
141 'gitweb_run "p=.git;a=commitdiff"'
142 test_debug 'cat gitweb.log'
144 test_expect_success \
145 '.git commitdiff_plain (implicit HEAD, root commit)' \
146 'gitweb_run "p=.git;a=commitdiff_plain"'
147 test_debug 'cat gitweb.log'
149 test_expect_success \
150 '.git commit (HEAD)' \
151 'gitweb_run "p=.git;a=commit;h=HEAD"'
152 test_debug 'cat gitweb.log'
154 test_expect_success \
155 '.git tree (implicit HEAD)' \
156 'gitweb_run "p=.git;a=tree"'
157 test_debug 'cat gitweb.log'
159 test_expect_success \
160 '.git blob (file)' \
161 'gitweb_run "p=.git;a=blob;f=file"'
162 test_debug 'cat gitweb.log'
164 test_expect_success \
165 '.git blob_plain (file)' \
166 'gitweb_run "p=.git;a=blob_plain;f=file"'
167 test_debug 'cat gitweb.log'
169 # ----------------------------------------------------------------------
170 # nonexistent objects
172 test_expect_success \
173 '.git commit (non-existent)' \
174 'gitweb_run "p=.git;a=commit;h=non-existent"'
175 test_debug 'cat gitweb.log'
177 test_expect_success \
178 '.git commitdiff (non-existent)' \
179 'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
180 test_debug 'cat gitweb.log'
182 test_expect_success \
183 '.git commitdiff (non-existent vs HEAD)' \
184 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
185 test_debug 'cat gitweb.log'
187 test_expect_success \
188 '.git tree (0000000000000000000000000000000000000000)' \
189 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
190 test_debug 'cat gitweb.log'
192 test_expect_success \
193 '.git tag (0000000000000000000000000000000000000000)' \
194 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
195 test_debug 'cat gitweb.log'
197 test_expect_success \
198 '.git blob (non-existent)' \
199 'gitweb_run "p=.git;a=blob;f=non-existent"'
200 test_debug 'cat gitweb.log'
202 test_expect_success \
203 '.git blob_plain (non-existent)' \
204 'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
205 test_debug 'cat gitweb.log'
208 # ----------------------------------------------------------------------
209 # commitdiff testing (implicit, one implicit tree-ish)
211 test_expect_success \
212 'commitdiff(0): root' \
213 'gitweb_run "p=.git;a=commitdiff"'
214 test_debug 'cat gitweb.log'
216 test_expect_success \
217 'commitdiff(0): file added' \
218 'echo "New file" > new_file &&
219 git add new_file &&
220 git commit -a -m "File added." &&
221 gitweb_run "p=.git;a=commitdiff"'
222 test_debug 'cat gitweb.log'
224 test_expect_success \
225 'commitdiff(0): mode change' \
226 'chmod a+x new_file &&
227 git commit -a -m "Mode changed." &&
228 gitweb_run "p=.git;a=commitdiff"'
229 test_debug 'cat gitweb.log'
231 test_expect_success \
232 'commitdiff(0): file renamed' \
233 'git mv new_file renamed_file &&
234 git commit -a -m "File renamed." &&
235 gitweb_run "p=.git;a=commitdiff"'
236 test_debug 'cat gitweb.log'
238 test_expect_success \
239 'commitdiff(0): file to symlink' \
240 'rm renamed_file &&
241 ln -s file renamed_file &&
242 git commit -a -m "File to symlink." &&
243 gitweb_run "p=.git;a=commitdiff"'
244 test_debug 'cat gitweb.log'
246 test_expect_success \
247 'commitdiff(0): file deleted' \
248 'git rm renamed_file &&
249 rm -f renamed_file &&
250 git commit -a -m "File removed." &&
251 gitweb_run "p=.git;a=commitdiff"'
252 test_debug 'cat gitweb.log'
254 test_expect_success \
255 'commitdiff(0): file copied / new file' \
256 'cp file file2 &&
257 git add file2 &&
258 git commit -a -m "File copied." &&
259 gitweb_run "p=.git;a=commitdiff"'
260 test_debug 'cat gitweb.log'
262 test_expect_success \
263 'commitdiff(0): mode change and modified' \
264 'echo "New line" >> file2 &&
265 chmod a+x file2 &&
266 git commit -a -m "Mode change and modification." &&
267 gitweb_run "p=.git;a=commitdiff"'
268 test_debug 'cat gitweb.log'
270 test_expect_success \
271 'commitdiff(0): renamed and modified' \
272 'cat >file2<<EOF &&
273 Dominus regit me,
274 et nihil mihi deerit.
275 In loco pascuae ibi me collocavit,
276 super aquam refectionis educavit me;
277 animam meam convertit,
278 deduxit me super semitas jusitiae,
279 propter nomen suum.
281 git commit -a -m "File added." &&
282 git mv file2 file3 &&
283 echo "Propter nomen suum." >> file3 &&
284 git commit -a -m "File rename and modification." &&
285 gitweb_run "p=.git;a=commitdiff"'
286 test_debug 'cat gitweb.log'
288 test_expect_success \
289 'commitdiff(0): renamed, mode change and modified' \
290 'git mv file3 file2 &&
291 echo "Propter nomen suum." >> file2 &&
292 chmod a+x file2 &&
293 git commit -a -m "File rename, mode change and modification." &&
294 gitweb_run "p=.git;a=commitdiff"'
295 test_debug 'cat gitweb.log'
297 # ----------------------------------------------------------------------
298 # commitdiff testing (taken from t4114-apply-typechange.sh)
300 test_expect_success 'setup typechange commits' '
301 echo "hello world" > foo &&
302 echo "hi planet" > bar &&
303 git update-index --add foo bar &&
304 git commit -m initial &&
305 git branch initial &&
306 rm -f foo &&
307 ln -s bar foo &&
308 git update-index foo &&
309 git commit -m "foo symlinked to bar" &&
310 git branch foo-symlinked-to-bar &&
311 rm -f foo &&
312 echo "how far is the sun?" > foo &&
313 git update-index foo &&
314 git commit -m "foo back to file" &&
315 git branch foo-back-to-file &&
316 rm -f foo &&
317 git update-index --remove foo &&
318 mkdir foo &&
319 echo "if only I knew" > foo/baz &&
320 git update-index --add foo/baz &&
321 git commit -m "foo becomes a directory" &&
322 git branch "foo-becomes-a-directory" &&
323 echo "hello world" > foo/baz &&
324 git update-index foo/baz &&
325 git commit -m "foo/baz is the original foo" &&
326 git branch foo-baz-renamed-from-foo
329 test_expect_success \
330 'commitdiff(2): file renamed from foo to foo/baz' \
331 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
332 test_debug 'cat gitweb.log'
334 test_expect_success \
335 'commitdiff(2): file renamed from foo/baz to foo' \
336 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
337 test_debug 'cat gitweb.log'
339 test_expect_success \
340 'commitdiff(2): directory becomes file' \
341 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
342 test_debug 'cat gitweb.log'
344 test_expect_success \
345 'commitdiff(2): file becomes directory' \
346 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
347 test_debug 'cat gitweb.log'
349 test_expect_success \
350 'commitdiff(2): file becomes symlink' \
351 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
352 test_debug 'cat gitweb.log'
354 test_expect_success \
355 'commitdiff(2): symlink becomes file' \
356 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
357 test_debug 'cat gitweb.log'
359 test_expect_success \
360 'commitdiff(2): symlink becomes directory' \
361 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
362 test_debug 'cat gitweb.log'
364 test_expect_success \
365 'commitdiff(2): directory becomes symlink' \
366 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
367 test_debug 'cat gitweb.log'
369 # ----------------------------------------------------------------------
370 # commit, commitdiff: merge, large
371 test_expect_success \
372 'Create a merge' \
373 'git checkout b &&
374 echo "Branch" >> b &&
375 git add b &&
376 git commit -a -m "On branch" &&
377 git checkout master &&
378 git pull . b'
380 test_expect_success \
381 'commit(0): merge commit' \
382 'gitweb_run "p=.git;a=commit"'
383 test_debug 'cat gitweb.log'
385 test_expect_success \
386 'commitdiff(0): merge commit' \
387 'gitweb_run "p=.git;a=commitdiff"'
388 test_debug 'cat gitweb.log'
390 test_expect_success \
391 'Prepare large commit' \
392 'git checkout b &&
393 echo "To be changed" > 01-change &&
394 echo "To be renamed" > 02-pure-rename-from &&
395 echo "To be deleted" > 03-delete &&
396 echo "To be renamed and changed" > 04-rename-from &&
397 echo "To have mode changed" > 05-mode-change &&
398 echo "File to symlink" > 06-file-or-symlink &&
399 echo "To be changed and have mode changed" > 07-change-mode-change &&
400 git add 0* &&
401 git commit -a -m "Prepare large commit" &&
402 echo "Changed" > 01-change &&
403 git mv 02-pure-rename-from 02-pure-rename-to &&
404 git rm 03-delete && rm -f 03-delete &&
405 echo "A new file" > 03-new &&
406 git add 03-new &&
407 git mv 04-rename-from 04-rename-to &&
408 echo "Changed" >> 04-rename-to &&
409 chmod a+x 05-mode-change &&
410 rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
411 echo "Changed and have mode changed" > 07-change-mode-change &&
412 chmod a+x 07-change-mode-change &&
413 git commit -a -m "Large commit" &&
414 git checkout master'
416 test_expect_success \
417 'commit(1): large commit' \
418 'gitweb_run "p=.git;a=commit;h=b"'
419 test_debug 'cat gitweb.log'
421 test_expect_success \
422 'commitdiff(1): large commit' \
423 'gitweb_run "p=.git;a=commitdiff;h=b"'
424 test_debug 'cat gitweb.log'
426 # ----------------------------------------------------------------------
427 # tags testing
429 test_expect_success \
430 'tags: list of different types of tags' \
431 'git checkout master &&
432 git tag -a -m "Tag commit object" tag-commit HEAD &&
433 git tag -a -m "" tag-commit-nomessage HEAD &&
434 git tag -a -m "Tag tag object" tag-tag tag-commit &&
435 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
436 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
437 git tag lightweight/tag-commit HEAD &&
438 git tag lightweight/tag-tag tag-commit &&
439 git tag lightweight/tag-tree HEAD^{tree} &&
440 git tag lightweight/tag-blob HEAD:file &&
441 gitweb_run "p=.git;a=tags"'
442 test_debug 'cat gitweb.log'
444 test_expect_success \
445 'tag: Tag to commit object' \
446 'gitweb_run "p=.git;a=tag;h=tag-commit"'
447 test_debug 'cat gitweb.log'
449 test_expect_success \
450 'tag: on lightweight tag (invalid)' \
451 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
452 test_debug 'cat gitweb.log'
454 # ----------------------------------------------------------------------
455 # logs
457 test_expect_success \
458 'logs: log (implicit HEAD)' \
459 'gitweb_run "p=.git;a=log"'
460 test_debug 'cat gitweb.log'
462 test_expect_success \
463 'logs: shortlog (implicit HEAD)' \
464 'gitweb_run "p=.git;a=shortlog"'
465 test_debug 'cat gitweb.log'
467 test_expect_success \
468 'logs: history (implicit HEAD, file)' \
469 'gitweb_run "p=.git;a=history;f=file"'
470 test_debug 'cat gitweb.log'
472 # ----------------------------------------------------------------------
473 # feed generation
475 test_expect_success \
476 'feeds: OPML' \
477 'gitweb_run "a=opml"'
478 test_debug 'cat gitweb.log'
480 test_expect_success \
481 'feed: RSS' \
482 'gitweb_run "p=.git;a=rss"'
483 test_debug 'cat gitweb.log'
485 test_expect_success \
486 'feed: Atom' \
487 'gitweb_run "p=.git;a=atom"'
488 test_debug 'cat gitweb.log'
490 # ----------------------------------------------------------------------
491 # encoding/decoding
493 test_expect_success \
494 'encode(commit): utf8' \
495 '. ../t3901-utf8.txt &&
496 echo "UTF-8" >> file &&
497 git add file &&
498 git commit -F ../t3900/1-UTF-8.txt &&
499 gitweb_run "p=.git;a=commit"'
500 test_debug 'cat gitweb.log'
502 test_expect_success \
503 'encode(commit): iso-8859-1' \
504 '. ../t3901-8859-1.txt &&
505 echo "ISO-8859-1" >> file &&
506 git add file &&
507 git config i18n.commitencoding ISO-8859-1 &&
508 git commit -F ../t3900/ISO-8859-1.txt &&
509 git config --unset i18n.commitencoding &&
510 gitweb_run "p=.git;a=commit"'
511 test_debug 'cat gitweb.log'
513 test_expect_success \
514 'encode(log): utf-8 and iso-8859-1' \
515 'gitweb_run "p=.git;a=log"'
516 test_debug 'cat gitweb.log'
518 test_done