3 # Copyright (c) 2007 Jakub Narebski
7 safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
8 cat >gitweb_config.perl <<EOF
11 # gitweb configuration for tests
13 our \$version = 'current';
15 our \$projectroot = "$safe_pwd";
16 our \$project_maxdepth = 8;
17 our \$home_link_str = 'projects';
18 our \$site_name = '[localhost]';
19 our \$site_html_head_string = '';
20 our \$site_header = '';
21 our \$site_footer = '';
22 our \$home_text = 'indextext.html';
23 our @stylesheets = ('file:///$GIT_BUILD_DIR/gitweb/static/gitweb.css');
24 our \$logo = 'file:///$GIT_BUILD_DIR/gitweb/static/git-logo.png';
25 our \$favicon = 'file:///$GIT_BUILD_DIR/gitweb/static/git-favicon.png';
26 our \$projects_list = '';
28 our \$strict_export = '';
29 our \$maxload = undef;
33 cat >.git/description <<EOF
37 # You can set the GITWEB_TEST_INSTALLED environment variable to
38 # the gitwebdir (the directory where gitweb is installed / deployed to)
39 # of an existing gitweb instalation to test that installation,
40 # or simply to pathname of installed gitweb script.
41 if test -n "$GITWEB_TEST_INSTALLED" ; then
42 if test -d $GITWEB_TEST_INSTALLED; then
43 SCRIPT_NAME="$GITWEB_TEST_INSTALLED/gitweb.cgi"
45 SCRIPT_NAME="$GITWEB_TEST_INSTALLED"
47 test -f "$SCRIPT_NAME" ||
48 error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
49 say "# Testing $SCRIPT_NAME"
50 else # normal case, use source version of gitweb
51 SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
57 GATEWAY_INTERFACE='CGI/1.1'
62 export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \
63 QUERY_STRING PATH_INFO
65 GITWEB_CONFIG=$(pwd)/gitweb_config.perl
68 # some of git commands write to STDERR on error, but this is not
69 # written to web server logs, so we are not interested in that:
70 # we are interested only in properly formatted errors/warnings
72 "$PERL_PATH" -- "$SCRIPT_NAME" \
73 >gitweb.output 2>gitweb.log &&
75 open O, ">gitweb.headers";
78 last if (/^\r$/ || /^$/);
80 open O, ">gitweb.body";
86 if grep '^[[]' gitweb.log >/dev/null 2>&1; then
87 test_debug 'cat gitweb.log >&2' &&
93 # gitweb.log is left for debugging
94 # gitweb.output is used to parse HTTP output
95 # gitweb.headers contains only HTTP headers
96 # gitweb.body contains body of message, without headers
101 if ! test_have_prereq PERL; then
102 skip_all='skipping gitweb tests, perl not available'
106 perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
107 skip_all='skipping gitweb tests, perl version is too old'
111 perl -MCGI -MCGI::Util -MCGI::Carp -e 0 >/dev/null 2>&1 || {
112 skip_all='skipping gitweb tests, CGI module unusable'