Skip to content

Commit 0552607

Browse files
ferrous26gitster
authored andcommitted
gitweb: split test suite into library and tests
To accommodate additions to the test cases for gitweb, the preamble from t9500 is now in its own library so that new sets of tests for gitweb can use the same setup without copying the code. Signed-off-by: Mark Rada <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34b31a8 commit 0552607

File tree

2 files changed

+74
-66
lines changed

2 files changed

+74
-66
lines changed

t/gitweb-lib.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2007 Jakub Narebski
4+
#
5+
6+
gitweb_init () {
7+
safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
8+
cat >gitweb_config.perl <<EOF
9+
#!/usr/bin/perl
10+
11+
# gitweb configuration for tests
12+
13+
our \$version = 'current';
14+
our \$GIT = 'git';
15+
our \$projectroot = "$safe_pwd";
16+
our \$project_maxdepth = 8;
17+
our \$home_link_str = 'projects';
18+
our \$site_name = '[localhost]';
19+
our \$site_header = '';
20+
our \$site_footer = '';
21+
our \$home_text = 'indextext.html';
22+
our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/gitweb.css');
23+
our \$logo = 'file:///$TEST_DIRECTORY/../gitweb/git-logo.png';
24+
our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png';
25+
our \$projects_list = '';
26+
our \$export_ok = '';
27+
our \$strict_export = '';
28+
29+
EOF
30+
31+
cat >.git/description <<EOF
32+
$0 test repository
33+
EOF
34+
}
35+
36+
gitweb_run () {
37+
GATEWAY_INTERFACE='CGI/1.1'
38+
HTTP_ACCEPT='*/*'
39+
REQUEST_METHOD='GET'
40+
SCRIPT_NAME="$TEST_DIRECTORY/../gitweb/gitweb.perl"
41+
QUERY_STRING=""$1""
42+
PATH_INFO=""$2""
43+
export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \
44+
SCRIPT_NAME QUERY_STRING PATH_INFO
45+
46+
GITWEB_CONFIG=$(pwd)/gitweb_config.perl
47+
export GITWEB_CONFIG
48+
49+
# some of git commands write to STDERR on error, but this is not
50+
# written to web server logs, so we are not interested in that:
51+
# we are interested only in properly formatted errors/warnings
52+
rm -f gitweb.log &&
53+
perl -- "$SCRIPT_NAME" \
54+
>gitweb.output 2>gitweb.log &&
55+
if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
56+
57+
# gitweb.log is left for debugging
58+
# gitweb.output is used to parse http output
59+
}
60+
61+
. ./test-lib.sh
62+
63+
if ! test_have_prereq PERL; then
64+
say 'skipping gitweb tests, perl not available'
65+
test_done
66+
fi
67+
68+
perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
69+
say 'skipping gitweb tests, perl version is too old'
70+
test_done
71+
}
72+
73+
gitweb_init

t/t9500-gitweb-standalone-no-errors.sh

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,8 @@ This test runs gitweb (git web interface) as CGI script from
99
commandline, and checks that it would not write any errors
1010
or warnings to log.'
1111

12-
gitweb_init () {
13-
safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
14-
cat >gitweb_config.perl <<EOF
15-
#!/usr/bin/perl
16-
17-
# gitweb configuration for tests
18-
19-
our \$version = "current";
20-
our \$GIT = "git";
21-
our \$projectroot = "$safe_pwd";
22-
our \$project_maxdepth = 8;
23-
our \$home_link_str = "projects";
24-
our \$site_name = "[localhost]";
25-
our \$site_header = "";
26-
our \$site_footer = "";
27-
our \$home_text = "indextext.html";
28-
our @stylesheets = ("file:///$TEST_DIRECTORY/../gitweb/gitweb.css");
29-
our \$logo = "file:///$TEST_DIRECTORY/../gitweb/git-logo.png";
30-
our \$favicon = "file:///$TEST_DIRECTORY/../gitweb/git-favicon.png";
31-
our \$projects_list = "";
32-
our \$export_ok = "";
33-
our \$strict_export = "";
3412

35-
EOF
36-
37-
cat >.git/description <<EOF
38-
$0 test repository
39-
EOF
40-
}
41-
42-
gitweb_run () {
43-
GATEWAY_INTERFACE="CGI/1.1"
44-
HTTP_ACCEPT="*/*"
45-
REQUEST_METHOD="GET"
46-
SCRIPT_NAME="$TEST_DIRECTORY/../gitweb/gitweb.perl"
47-
QUERY_STRING=""$1""
48-
PATH_INFO=""$2""
49-
export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \
50-
SCRIPT_NAME QUERY_STRING PATH_INFO
51-
52-
GITWEB_CONFIG=$(pwd)/gitweb_config.perl
53-
export GITWEB_CONFIG
54-
55-
# some of git commands write to STDERR on error, but this is not
56-
# written to web server logs, so we are not interested in that:
57-
# we are interested only in properly formatted errors/warnings
58-
rm -f gitweb.log &&
59-
perl -- "$SCRIPT_NAME" \
60-
>/dev/null 2>gitweb.log &&
61-
if grep "^[[]" gitweb.log >/dev/null 2>&1; then false; else true; fi
62-
63-
# gitweb.log is left for debugging
64-
}
65-
66-
. ./test-lib.sh
67-
68-
if ! test_have_prereq PERL; then
69-
say 'skipping gitweb tests, perl not available'
70-
test_done
71-
fi
72-
73-
perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
74-
say 'skipping gitweb tests, perl version is too old'
75-
test_done
76-
}
77-
78-
gitweb_init
13+
. ./gitweb-lib.sh
7914

8015
# ----------------------------------------------------------------------
8116
# no commits (empty, just initialized repository)

0 commit comments

Comments
 (0)