git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] gitweb test script
@ 2006-08-06 16:51 Matthias Lederhofer
  2006-08-06 21:38 ` Junio C Hamano
  2006-08-07  8:31 ` Matthias Lederhofer
  0 siblings, 2 replies; 3+ messages in thread
From: Matthias Lederhofer @ 2006-08-06 16:51 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC] gitweb test script
  2006-08-06 16:51 [RFC] gitweb test script Matthias Lederhofer
@ 2006-08-06 21:38 ` Junio C Hamano
  2006-08-07  8:31 ` Matthias Lederhofer
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2006-08-06 21:38 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: git

Matthias Lederhofer <matled@gmx.net> writes:

> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] gitweb test script
  2006-08-06 16:51 [RFC] gitweb test script Matthias Lederhofer
  2006-08-06 21:38 ` Junio C Hamano
@ 2006-08-07  8:31 ` Matthias Lederhofer
  1 sibling, 0 replies; 3+ messages in thread
From: Matthias Lederhofer @ 2006-08-07  8:31 UTC (permalink / raw)
  To: git

Matthias Lederhofer <matled@gmx.net> wrote:
> +TOPDIR="`pwd``git rev-parse --show-cdup`"

This should be
TOPDIR="`pwd`/`git rev-parse --show-cdup`"

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-07  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-06 16:51 [RFC] gitweb test script Matthias Lederhofer
2006-08-06 21:38 ` Junio C Hamano
2006-08-07  8:31 ` Matthias Lederhofer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).