gitweb: Check that RSS, Atom and OPML output is well formed XML
[git/jnareb-git/bp-gitweb.git] / t / t9503-gitweb-Mechanize.sh
blob8720aea642b903a3bfd8efe55610bb348c407dbc
1 #!/bin/sh
3 # Copyright (c) 2008 Jakub Narebski
6 test_description='gitweb as CGI (using WWW::Mechanize)
8 This test uses Perl module Test::WWW::Mechanize::CGI to
9 check gitweb output, using HTML::Lint to validate HTML.'
11 # helper functions
13 safe_chmod () {
14 chmod "$1" "$2" &&
15 if [ "$(git config --get core.filemode)" = false ]
16 then
17 git update-index --chmod="$1" "$2"
21 . ./test-lib.sh
23 # check if test can be run
24 perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
25 test_expect_success \
26 'skipping gitweb tests, perl version is too old' :
27 test_done
28 exit
31 perl -MTest::WWW::Mechanize::CGI -e '' >/dev/null 2>&1 || {
32 test_expect_success \
33 'skipping gitweb tests, Test::WWW::Mechanize::CGI not found' :
34 test_done
35 exit
38 # set up test repository
39 test_expect_success 'set up test repository' '
41 echo "Not an empty file." > file &&
42 git add file &&
43 test_tick && git commit -a -m "Initial commit." &&
44 git branch b &&
46 echo "New file" > new_file &&
47 git add new_file &&
48 test_tick && git commit -a -m "File added." &&
50 safe_chmod +x new_file &&
51 test_tick && git commit -a -m "Mode changed." &&
53 git mv new_file renamed_file &&
54 test_tick && git commit -a -m "File renamed." &&
56 rm renamed_file &&
57 ln -s file renamed_file &&
58 test_tick && git commit -a -m "File to symlink." &&
59 git tag with-symlink &&
61 git rm renamed_file &&
62 rm -f renamed_file &&
63 test_tick && git commit -a -m "File removed." &&
65 cp file file2 &&
66 git add file2 &&
67 test_tick && git commit -a -m "File copied." &&
69 echo "New line" >> file2 &&
70 safe_chmod +x file2 &&
71 test_tick && git commit -a -m "Mode change and modification." &&
73 git checkout b &&
74 echo "Branch" >> b &&
75 git add b &&
76 test_tick && git commit -a -m "On branch" &&
77 git checkout master &&
78 test_tick && git pull . b
81 # set up empty repository
82 # TODO!
84 # set up repositories for gitweb
85 # TODO!
87 # set up gitweb configuration
88 safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
89 cat >gitweb_config.perl <<EOF
90 #!/usr/bin/perl
92 # gitweb configuration for tests
94 our \$version = "current";
95 our \$GIT = "$GIT_EXEC_PATH/git";
96 our \$projectroot = "$safe_pwd";
97 our \$project_maxdepth = 8;
98 our \$home_link_str = "projects";
99 our \$site_name = "[localhost]";
100 our \$site_header = "";
101 our \$site_footer = "";
102 our \$home_text = "indextext.html";
103 our @stylesheets = ("file:///$safe_pwd/../../gitweb/gitweb.css");
104 our \$logo = "file:///$safe_pwd/../../gitweb/git-logo.png";
105 our \$favicon = "file:///$safe_pwd/../../gitweb/git-favicon.png";
106 our \$projects_list = "";
107 our \$export_ok = "";
108 our \$strict_export = "";
111 __END__
114 cat >.git/description <<EOF
115 $0 test repository
118 GITWEB_CONFIG="$(pwd)/gitweb_config.perl"
119 export GITWEB_CONFIG
121 # run tests
123 test_external \
124 'test gitweb output' \
125 perl ../t9503/test.pl
127 test_done