git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC] gitweb test script

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Aug 6, 2006, 16:51 UTC
Message-ID
<20060806165151.GB9548@moooo.ath.cx>

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
Next: Junio C Hamano
Message 1 of 3 in “[RFC] gitweb test script”
  1. Matthias LederhoferAug 6, 2006
  2. Junio C HamanoAug 6, 2006
  3. Matthias LederhoferAug 7, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.