#!/bin/sh # # Copyright (c) 2007 Jakub Narebski # test_description='gitweb as standalone script (basic tests). This test runs gitweb (git web interface) as CGI script from commandline, and checks that it does not spew any errors or warnings.' gitweb_init () { cat >gitweb_config.perl </dev/null 2>gitweb.log && test ! -s gitweb.log } . ./test-lib.sh gitweb_init #test_debug 'cat $(pwd)/gitweb_config.perl' # ---------------------------------------------------------------------- # no commits test_expect_success \ 'no commits: projects_list (implicit)' \ 'gitweb_run' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: projects_index' \ 'gitweb_run "a=project_index"' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: .git summary (implicit)' \ 'gitweb_run "p=.git"' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: .git commit (implicit)' \ 'gitweb_run "p=.git;a=commit"' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: .git tree (implicit)' \ 'gitweb_run "p=.git;a=tree"' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: .git heads (implicit)' \ 'gitweb_run "p=.git;a=heads"' test_debug 'cat gitweb.log' test_expect_success \ 'no commits: .git tags (implicit)' \ 'gitweb_run "p=.git;a=tags"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # initial commit test_expect_success \ 'make initial commit' \ 'echo "Not an empty file." > file && git add file && git commit -a -m "Initial commit." && git branch b' test_expect_success \ 'projects_list (implicit)' \ 'gitweb_run' test_debug 'cat gitweb.log' test_expect_success \ 'projects_index' \ 'gitweb_run "a=project_index"' test_debug 'cat gitweb.log' test_expect_success \ '.git summary (implicit)' \ 'gitweb_run "p=.git"' test_debug 'cat gitweb.log' test_expect_success \ '.git commit (implicit)' \ 'gitweb_run "p=.git;a=commit"' test_debug 'cat gitweb.log' test_expect_success \ '.git commitdiff (implicit)' \ 'gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ '.git commit (HEAD)' \ 'gitweb_run "p=.git;a=commit;h=HEAD"' test_debug 'cat gitweb.log' test_expect_success \ '.git commit (..invalid^..)' \ 'gitweb_run "p=.git;a=commit;h=..invalid^.."' test_debug 'cat gitweb.log' test_expect_success \ '.git tree (implicit)' \ 'gitweb_run "p=.git;a=tree"' test_debug 'cat gitweb.log' test_expect_success \ '.git blob (file)' \ 'gitweb_run "p=.git;a=blob;f=file"' test_debug 'cat gitweb.log' test_expect_success \ '.git blob_plain (file)' \ 'gitweb_run "p=.git;a=blob_plain;f=file"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # nonexistent objects test_expect_success \ '.git commit (non-existent)' \ 'gitweb_run "p=.git;a=commit;h=non-existent"' test_debug 'cat gitweb.log' test_expect_success \ '.git commitdiff (non-existent)' \ 'gitweb_run "p=.git;a=commitdiff;h=non-existent"' test_debug 'cat gitweb.log' test_expect_success \ '.git tree (0000000000000000000000000000000000000000)' \ 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"' test_debug 'cat gitweb.log' test_expect_success \ '.git blob (non-existent)' \ 'gitweb_run "p=.git;a=blob;f=non-existent"' test_debug 'cat gitweb.log' test_expect_success \ '.git blob_plain (non-existent)' \ 'gitweb_run "p=.git;a=blob_plain;f=non-existent"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # commitdiff testing (implicit, one implicit tree-ish) test_expect_success \ 'commitdiff: root' \ 'gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: file added' \ 'echo "New file" > new_file && git add new_file && git commit -a -m "File added." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: mode change' \ 'chmod a+x new_file && git commit -a -m "Mode changed." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: file renamed' \ 'git mv new_file renamed_file && git commit -a -m "File renamed." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: file to symlink' \ 'rm renamed_file && ln -s file renamed_file && git commit -a -m "File to symlink." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: file deleted' \ 'git rm renamed_file && rm -f renamed_file && git commit -a -m "File removed." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: file copied / new file' \ 'cp file file2 && git add file2 && git commit -a -m "File copied." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: mode change and modified' \ 'echo "New line" >> file2 && chmod a+x file2 && git commit -a -m "Mode change and modification." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: renamed and modified' \ 'cat >file2<> file3 && git commit -a -m "File rename and modification." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff: renamed, mode change and modified' \ 'git mv file3 file2 && echo "Propter nomen suum." >> file2 && chmod a+x file2 && git commit -a -m "File rename, mode change and modification." && gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # commitdiff testing (taken from t4114-apply-typechange.sh) test_expect_success 'setup typechange commits' ' echo "hello world" > foo && echo "hi planet" > bar && git update-index --add foo bar && git commit -m initial && git branch initial && rm -f foo && ln -s bar foo && git update-index foo && git commit -m "foo symlinked to bar" && git branch foo-symlinked-to-bar && rm -f foo && echo "how far is the sun?" > foo && git update-index foo && git commit -m "foo back to file" && git branch foo-back-to-file && rm -f foo && git update-index --remove foo && mkdir foo && echo "if only I knew" > foo/baz && git update-index --add foo/baz && git commit -m "foo becomes a directory" && git branch "foo-becomes-a-directory" && echo "hello world" > foo/baz && git update-index foo/baz && git commit -m "foo/baz is the original foo" && git branch foo-baz-renamed-from-foo ' test_expect_success \ 'commitdiff(2): file renamed from foo to foo/baz' \ 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): file renamed from foo/baz to foo' \ 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): directory becomes file' \ 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): file becomes directory' \ 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): file becomes symlink' \ 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): symlink becomes file' \ 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): symlink becomes directory' \ 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"' test_debug 'cat gitweb.log' test_expect_success \ 'commitdiff(2): directory becomes symlink' \ 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # commitdiff large test_expect_success \ 'create a merge' \ 'git checkout b && echo "Branch" >> b && git add b && git commit -a -m "On branch" && git checkout master && git pull . b' test_expect_success \ 'commitdiff: merge commit' \ 'gitweb_run "p=.git;a=commitdiff"' test_debug 'cat gitweb.log' # ---------------------------------------------------------------------- # tags testing test_expect_success \ 'tags: different types of tags' \ 'git tag -a -m "Tag commit object" tag-commit HEAD && git tag -a -m "" tag-commit-nomessage HEAD && git tag -a -m "Tag tag object" tag-tag tag-commit && git tag -a -m "Tag tree object" tag-tree HEAD^{tree} && git tag -a -m "Tag blob object" tag-blob HEAD:file && git tag lightweight/tag-commit HEAD && git tag lightweight/tag-tag tag-commit && git tag lightweight/tag-tree HEAD^{tree} && git tag lightweight/tag-blob HEAD:file && gitweb_run "p=.git;a=tags"' test_debug 'cat gitweb.log' test_expect_success \ 'tag: Tag to commit object' \ 'gitweb_run "p=.git;a=tag;h=tag-commit"' test_debug 'cat gitweb.log' test_expect_success \ 'tag: on lightweight tag (invalid)' \ 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"' test_debug 'cat gitweb.log' test_done