threads / rfc / 5158

[RFC] gitweb test script

Subject: [RFC] gitweb test script

## tl;dr

3 messages between Aug 6, 2006 and Aug 7, 2006.

replies: 2people: 2as markdown or json

Matthias Lederhofer· Aug 6, 2006, 16:51 UTC · lore

Perhaps this script has a place in the git repository. Creating some automated tests at least checking for warnings should be easy too. This should work from the git repository and makes gitweb use .git as repository. At the moment it still needs the git binary to be in the path already to find the top repository directory.

This could also be extended for automated tests. Here is an example how this could look like (currently this does not test much of gitweb):

#!/bin/sh
die() {
	echo "$0: $*" >&2
	exit 1
}
cleanup() {
	[ -e "$TMP" ] && rm "$TMP"
}
test() {
	echo "test: $@"
	"$gitweb" "$@" > /dev/null 2> "$TMP"
	if [ ! -s "$TMP" ]; then
		return
	fi
	echo "========== ERRORS =========="
	cat "$TMP"
	echo "============================"
}

gitweb="./`git rev-parse --show-cdup`/t/gitweb.sh" TMP="" trap cleanup EXIT TMP="`mktemp`" || die mktemp failed

# repository overview test # summary test p=.git

# commitdiff
# initial commit
test p=.git a=commitdiff \
	h=e83c5163316f89bfbde7d9ab23ca2e25604af290
# some other commit
test p=.git a=commitdiff \
	h=5a716826a6f7f209777f344143cdd9e4f2903097
# merge commit withouth specified parent
test p=.git a=commitdiff \
	h=e190bc55431d906b8c70dc07f8b6d823721f12c9
# merge commit with specified parent
test p=.git a=commitdiff \
	h=e190bc55431d906b8c70dc07f8b6d823721f12c9 \
	hp=360204c324ca9178e2bcb4d75f3986201f8ac7e1
---
 t/gitweb.sh          |   29 +++++++++++++++++++++++++++++
 t/gitweb_config.perl |    4 ++++
 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/t/gitweb.sh b/t/gitweb.sh
new file mode 100755
index 0000000..b0dff26
--- /dev/null
+++ b/t/gitweb.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# this script runs gitweb.perl from the shell having .git as repository
+# command line parameters are used as query string
+
+TOPDIR="`pwd``git rev-parse --show-cdup`"
+if [ ! -e "$TOPDIR/git" ]; then
+	echo "$0: You haven't built things yet, have you?" >&2
+	exit 1
+fi
+
+export PATH="$TOPDIR:$PATH"
+export GIT_EXEC_PATH="$TOPDIR"
+
+# cgi environment
+export GATEWAY_INTERFACE=CGI/1.1
+export REQUEST_METHOD=GET
+QUERY_STRING=""
+if [ $# -gt 0 ]; then
+	QUERY_STRING="$1"
+	shift
+fi
+while [ $# -gt 0 ]; do
+	QUERY_STRING="$QUERY_STRING;$1"
+	shift
+done
+export QUERY_STRING
+
+export GITWEB_CONFIG="$TOPDIR/t/gitweb_config.perl"
+exec "$TOPDIR/gitweb/gitweb.perl"
diff --git a/t/gitweb_config.perl b/t/gitweb_config.perl
new file mode 100644
index 0000000..5c245ff
--- /dev/null
+++ b/t/gitweb_config.perl
@@ -0,0 +1,4 @@
+$projectroot = "./".qx(git rev-parse --show-cdup);
+chomp($projectroot);
+$projects_list = $projectroot;
+$GIT = $projectroot.'/git';
-- 
1.4.1.gfd699
Junio C Hamano· Aug 6, 2006, 21:38 UTC · re: Matthias Lederhofer · lore

Re: [RFC] gitweb test script

Matthias Lederhofer <matled@gmx.net> writes:
Show 6 quoted lines
> Perhaps this script has a place in the git repository.
> Creating some automated tests at least checking for warnings
> should be easy too.  This should work from the git repository
> and makes gitweb use .git as repository.  At the moment it
> still needs the git binary to be in the path already to find
> the top repository directory.
A good start.  We really need something like this.

← back to recent threads