Skip to content

Commit 430fac9

Browse files
committed
Merge branch 'jn/gitweb-test'
* jn/gitweb-test: gitweb/Makefile: Include gitweb/config.mak gitweb/Makefile: Add 'test' and 'test-installed' targets t/gitweb-lib.sh: Add support for GITWEB_TEST_INSTALLED gitweb: Move call to evaluate_git_version after evaluate_gitweb_config
2 parents 8cf666c + 9b93aeb commit 430fac9

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

gitweb/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ HIGHLIGHT_BIN = highlight
4040
# include user config
4141
-include ../config.mak.autogen
4242
-include ../config.mak
43+
-include config.mak
4344

4445
# determine version
4546
../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -145,6 +146,15 @@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
145146
chmod +x $@+ && \
146147
mv $@+ $@
147148

149+
### Testing rules
150+
151+
test:
152+
$(MAKE) -C ../t gitweb-test
153+
154+
test-installed:
155+
GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
156+
$(MAKE) -C ../t gitweb-test
157+
148158
### Installation rules
149159

150160
install: all
@@ -158,5 +168,5 @@ install: all
158168
clean:
159169
$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
160170

161-
.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
171+
.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
162172

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@ sub run_request {
10751075

10761076
evaluate_uri();
10771077
evaluate_gitweb_config();
1078+
evaluate_git_version();
10781079
check_loadavg();
10791080

10801081
# $projectroot and $projects_list might be set in gitweb config file
@@ -1127,7 +1128,6 @@ sub evaluate_argv {
11271128

11281129
sub run {
11291130
evaluate_argv();
1130-
evaluate_git_version();
11311131

11321132
$pre_listen_hook->()
11331133
if $pre_listen_hook;

t/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1717

1818
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
1919
TSVN = $(wildcard t91[0-9][0-9]-*.sh)
20+
TGITWEB = $(wildcard t95[0-9][0-9]-*.sh)
2021

2122
all: pre-clean
2223
$(MAKE) aggregate-results-and-cleanup
@@ -46,6 +47,9 @@ full-svn-test:
4647
$(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
4748
$(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
4849

50+
gitweb-test:
51+
$(MAKE) $(TGITWEB)
52+
4953
valgrind:
5054
GIT_TEST_OPTS=--valgrind $(MAKE)
5155

t/gitweb-lib.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,34 @@ EOF
3232
cat >.git/description <<EOF
3333
$0 test repository
3434
EOF
35+
36+
# You can set the GITWEB_TEST_INSTALLED environment variable to
37+
# the gitwebdir (the directory where gitweb is installed / deployed to)
38+
# of an existing gitweb instalation to test that installation,
39+
# or simply to pathname of installed gitweb script.
40+
if test -n "$GITWEB_TEST_INSTALLED" ; then
41+
if test -d $GITWEB_TEST_INSTALLED; then
42+
SCRIPT_NAME="$GITWEB_TEST_INSTALLED/gitweb.cgi"
43+
else
44+
SCRIPT_NAME="$GITWEB_TEST_INSTALLED"
45+
fi
46+
test -f "$SCRIPT_NAME" ||
47+
error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
48+
say "# Testing $SCRIPT_NAME"
49+
else # normal case, use source version of gitweb
50+
SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
51+
fi
52+
export SCRIPT_NAME
3553
}
3654

3755
gitweb_run () {
3856
GATEWAY_INTERFACE='CGI/1.1'
3957
HTTP_ACCEPT='*/*'
4058
REQUEST_METHOD='GET'
41-
SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
4259
QUERY_STRING=""$1""
4360
PATH_INFO=""$2""
4461
export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \
45-
SCRIPT_NAME QUERY_STRING PATH_INFO
62+
QUERY_STRING PATH_INFO
4663

4764
GITWEB_CONFIG=$(pwd)/gitweb_config.perl
4865
export GITWEB_CONFIG

0 commit comments

Comments
 (0)