git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Add test t9500 for gitweb (as standalone script)
@ 2007-05-19  0:19 Jakub Narebski
  2007-06-17 15:39 ` Sven Verdoolaege
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Narebski @ 2007-05-19  0:19 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski

This test runs gitweb (git web interface) as CGI script from
commandline, and checks that it would not write any errors
or warnings to log.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is test I have used to find errors and warnings fixed in the
late 'Fix "Use of uninitialized value" warning ...' series.

It is not perfect, it does not offer full coverage, and tests
only if there are no errors or warning not checking the output,
not even HTTP code, but it helps.

 t/t9500-gitweb-standalone-no-errors.sh |  490 ++++++++++++++++++++++++++++++++
 1 files changed, 490 insertions(+), 0 deletions(-)
 create mode 100755 t/t9500-gitweb-standalone-no-errors.sh

diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
new file mode 100755
index 0000000..b92ab63
--- /dev/null
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -0,0 +1,490 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Jakub Narebski
+#
+
+test_description='gitweb as standalone script (basic tests).
+
+This test runs gitweb (git web interface) as CGI script from
+commandline, and checks that it would not write any errors
+or warnings to log.'
+
+gitweb_init () {
+	cat >gitweb_config.perl <<EOF
+#!/usr/bin/perl
+
+# gitweb configuration for tests
+
+our \$version = "current";
+our \$GIT = "git";
+our \$projectroot = "$(pwd)";
+our \$home_link_str = "projects";
+our \$site_name = "[localhost]";
+our \$site_header = "";
+our \$site_footer = "";
+our \$home_text = "indextext.html";
+our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
+our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
+our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
+our \$projects_list = "";
+our \$export_ok = "";
+our \$strict_export = "";
+
+CGI::Carp::set_programname("gitweb/gitweb.cgi");
+EOF
+
+	cat >.git/description <<EOF
+$0 test repository
+EOF
+}
+
+gitweb_run () {
+	export GATEWAY_INTERFACE="CGI/1.1"
+	export HTTP_ACCEPT="*/*"
+	export REQUEST_METHOD="GET"
+	export QUERY_STRING=""$1""
+	export PATH_INFO=""$2""
+
+	export GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+
+	# some of git commands write to STDERR on error, but this is not
+	# written to web server logs, so we are not interested in that:
+	# we are interested only in properly formatted errors/warnings
+	rm -f gitweb.log &&
+	perl -- $(pwd)/../../gitweb/gitweb.perl \
+		>/dev/null 2>gitweb.log &&
+	if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
+
+	# gitweb.log is left for debugging
+}
+
+. ./test-lib.sh
+
+gitweb_init
+
+# ----------------------------------------------------------------------
+# no commits (empty, just initialized repository)
+
+test_expect_success \
+	'no commits: projects_list (implicit)' \
+	'gitweb_run'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: projects_index' \
+	'gitweb_run "a=project_index"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git summary (implicit)' \
+	'gitweb_run "p=.git"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git commit (implicit HEAD)' \
+	'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git commitdiff (implicit HEAD)' \
+	'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git tree (implicit HEAD)' \
+	'gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git heads' \
+	'gitweb_run "p=.git;a=heads"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'no commits: .git tags' \
+	'gitweb_run "p=.git;a=tags"'
+test_debug 'cat gitweb.log'
+
+
+# ----------------------------------------------------------------------
+# initial commit
+
+test_expect_success \
+	'Make initial commit' \
+	'echo "Not an empty file." > file &&
+	 git add file &&
+	 git commit -a -m "Initial commit." &&
+	 git branch b'
+
+test_expect_success \
+	'projects_list (implicit)' \
+	'gitweb_run'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'projects_index' \
+	'gitweb_run "a=project_index"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git summary (implicit)' \
+	'gitweb_run "p=.git"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commit (implicit HEAD)' \
+	'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commitdiff (implicit HEAD, root commit)' \
+	'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commitdiff_plain (implicit HEAD, root commit)' \
+	'gitweb_run "p=.git;a=commitdiff_plain"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commit (HEAD)' \
+	'gitweb_run "p=.git;a=commit;h=HEAD"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git tree (implicit HEAD)' \
+	'gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git blob (file)' \
+	'gitweb_run "p=.git;a=blob;f=file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git blob_plain (file)' \
+	'gitweb_run "p=.git;a=blob_plain;f=file"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# nonexistent objects
+
+test_expect_success \
+	'.git commit (non-existent)' \
+	'gitweb_run "p=.git;a=commit;h=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commitdiff (non-existent)' \
+	'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git commitdiff (non-existent vs HEAD)' \
+	'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git tree (0000000000000000000000000000000000000000)' \
+	'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git tag (0000000000000000000000000000000000000000)' \
+	'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git blob (non-existent)' \
+	'gitweb_run "p=.git;a=blob;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'.git blob_plain (non-existent)' \
+	'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+
+# ----------------------------------------------------------------------
+# commitdiff testing (implicit, one implicit tree-ish)
+
+test_expect_success \
+	'commitdiff(0): root' \
+	'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): file added' \
+	'echo "New file" > new_file &&
+	 git add new_file &&
+	 git commit -a -m "File added." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): mode change' \
+	'chmod a+x new_file &&
+	 git commit -a -m "Mode changed." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): file renamed' \
+	'git mv new_file renamed_file &&
+	 git commit -a -m "File renamed." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): file to symlink' \
+	'rm renamed_file &&
+	 ln -s file renamed_file &&
+	 git commit -a -m "File to symlink." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): file deleted' \
+	'git rm renamed_file &&
+	 rm -f renamed_file &&
+	 git commit -a -m "File removed." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): file copied / new file' \
+	'cp file file2 &&
+	 git add file2 &&
+	 git commit -a -m "File copied." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): mode change and modified' \
+	'echo "New line" >> file2 &&
+	 chmod a+x file2 &&
+	 git commit -a -m "Mode change and modification." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): renamed and modified' \
+	'cat >file2<<EOF &&
+Dominus regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+EOF
+	 git commit -a -m "File added." &&
+	 git mv file2 file3 &&
+	 echo "Propter nomen suum." >> file3 &&
+	 git commit -a -m "File rename and modification." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): renamed, mode change and modified' \
+	'git mv file3 file2 &&
+	 echo "Propter nomen suum." >> file2 &&
+	 chmod a+x file2 &&
+	 git commit -a -m "File rename, mode change and modification." &&
+	 gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# commitdiff testing (taken from t4114-apply-typechange.sh)
+
+test_expect_success 'setup typechange commits' '
+	echo "hello world" > foo &&
+	echo "hi planet" > bar &&
+	git update-index --add foo bar &&
+	git commit -m initial &&
+	git branch initial &&
+	rm -f foo &&
+	ln -s bar foo &&
+	git update-index foo &&
+	git commit -m "foo symlinked to bar" &&
+	git branch foo-symlinked-to-bar &&
+	rm -f foo &&
+	echo "how far is the sun?" > foo &&
+	git update-index foo &&
+	git commit -m "foo back to file" &&
+	git branch foo-back-to-file &&
+	rm -f foo &&
+	git update-index --remove foo &&
+	mkdir foo &&
+	echo "if only I knew" > foo/baz &&
+	git update-index --add foo/baz &&
+	git commit -m "foo becomes a directory" &&
+	git branch "foo-becomes-a-directory" &&
+	echo "hello world" > foo/baz &&
+	git update-index foo/baz &&
+	git commit -m "foo/baz is the original foo" &&
+	git branch foo-baz-renamed-from-foo
+	'
+
+test_expect_success \
+	'commitdiff(2): file renamed from foo to foo/baz' \
+	'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): file renamed from foo/baz to foo' \
+	'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): directory becomes file' \
+	'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): file becomes directory' \
+	'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): file becomes symlink' \
+	'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): symlink becomes file' \
+	'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): symlink becomes directory' \
+	'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(2): directory becomes symlink' \
+	'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# commit, commitdiff: merge, large
+test_expect_success \
+	'Create a merge' \
+	'git checkout b &&
+	 echo "Branch" >> b &&
+	 git add b &&
+	 git commit -a -m "On branch" &&
+	 git checkout master &&
+	 git pull . b'
+
+test_expect_success \
+	'commit(0): merge commit' \
+	'gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(0): merge commit' \
+	'gitweb_run "p=.git;a=commitdiff"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'Prepare large commit' \
+	'git checkout b &&
+	 echo "To be changed" > 01-change &&
+	 echo "To be renamed" > 02-pure-rename-from &&
+	 echo "To be deleted" > 03-delete &&
+	 echo "To be renamed and changed" > 04-rename-from &&
+	 echo "To have mode changed" > 05-mode-change &&
+	 echo "File to symlink" > 06-file-or-symlink &&
+	 echo "To be changed and have mode changed" > 07-change-mode-change	&&
+	 git add 0* &&
+	 git commit -a -m "Prepare large commit" &&
+	 echo "Changed" > 01-change &&
+	 git mv 02-pure-rename-from 02-pure-rename-to &&
+	 git rm 03-delete && rm -f 03-delete &&
+	 echo "A new file" > 03-new &&
+	 git add 03-new &&
+	 git mv 04-rename-from 04-rename-to &&
+	 echo "Changed" >> 04-rename-to &&
+	 chmod a+x 05-mode-change &&
+	 rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
+	 echo "Changed and have mode changed" > 07-change-mode-change	&&
+	 chmod a+x 07-change-mode-change &&
+	 git commit -a -m "Large commit" &&
+	 git checkout master'
+
+test_expect_success \
+	'commit(1): large commit' \
+	'gitweb_run "p=.git;a=commit;h=b"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'commitdiff(1): large commit' \
+	'gitweb_run "p=.git;a=commitdiff;h=b"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# tags testing
+
+test_expect_success \
+	'tags: list of different types of tags' \
+	'git checkout master &&
+	 git tag -a -m "Tag commit object" tag-commit HEAD &&
+	 git tag -a -m "" tag-commit-nomessage HEAD &&
+	 git tag -a -m "Tag tag object" tag-tag tag-commit &&
+	 git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
+	 git tag -a -m "Tag blob object" tag-blob HEAD:file &&
+	 git tag lightweight/tag-commit HEAD &&
+	 git tag lightweight/tag-tag tag-commit &&
+	 git tag lightweight/tag-tree HEAD^{tree} &&
+	 git tag lightweight/tag-blob HEAD:file &&
+	 gitweb_run "p=.git;a=tags"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'tag: Tag to commit object' \
+	'gitweb_run "p=.git;a=tag;h=tag-commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'tag: on lightweight tag (invalid)' \
+	'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# logs
+
+test_expect_success \
+	'logs: log (implicit HEAD)' \
+	'gitweb_run "p=.git;a=log"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'logs: shortlog (implicit HEAD)' \
+	'gitweb_run "p=.git;a=shortlog"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'logs: history (implicit HEAD, file)' \
+	'gitweb_run "p=.git;a=history;f=file"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# feed generation
+
+test_expect_success \
+	'feeds: OPML' \
+	'gitweb_run "a=opml"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'feed: RSS' \
+	'gitweb_run "p=.git;a=rss"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'feed: Atom' \
+	'gitweb_run "p=.git;a=atom"'
+test_debug 'cat gitweb.log'
+
+test_done
-- 
1.5.1.4

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

* Re: [PATCH] gitweb: Add test t9500 for gitweb (as standalone script)
  2007-05-19  0:19 [PATCH] gitweb: Add test t9500 for gitweb (as standalone script) Jakub Narebski
@ 2007-06-17 15:39 ` Sven Verdoolaege
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Verdoolaege @ 2007-06-17 15:39 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On Sat, May 19, 2007 at 02:19:20AM +0200, Jakub Narebski wrote:
> This test runs gitweb (git web interface) as CGI script from
> commandline, and checks that it would not write any errors
> or warnings to log.

Could you please skip this test if the version of perl is too old?

In particular, I get
[Sun Jun 17 17:28:11 2007] gitweb.perl: Too many arguments for Encode::decode_utf8 at ../../gitweb/gitweb.perl line 618, near "Encode::FB_CROAK)"
[Sun Jun 17 17:28:11 2007] gitweb.perl: Execution of ../../gitweb/gitweb.perl aborted due to compilation errors.

My Encode.pm has

----
sub decode_utf8($)
{
    my ($str) = @_;
    return undef unless utf8::decode($str);
    return $str;
}
----

Curiously, it also has

----
=item $string = decode_utf8($octets [, CHECK]);
 
equivalent to C<$string = decode("utf8", $octets [, CHECK])>.
The sequence of octets represented by
$octets is decoded from UTF-8 into a sequence of logical
characters. Not all sequences of octets form valid UTF-8 encodings, so
it is possible for this call to fail.  For CHECK, see
L</"Handling Malformed Data">.
----


In any case, I don't feel like upgrading perl just for gitweb
on this machine.

bash-3.00$ perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.18, archname=i686-linux-thread-multi
    uname='linux greensroom 2.4.18 #2 smp fri jul 19 13:03:13 cest 2002 i686 unknown '
    config_args='-Doptimize=-g -Dprefix=/usr -Dusedevel -Dusethreads -Duseithreads -Duseshrplib -Dinstallusrbinperl -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3 20010315 (SuSE)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i686-linux-thread-multi/CORE'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Jul 19 2002 18:11:28
  @INC:
    /usr/lib/perl5/5.8.0/i686-linux-thread-multi
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    .

skimo

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

end of thread, other threads:[~2007-06-17 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-19  0:19 [PATCH] gitweb: Add test t9500 for gitweb (as standalone script) Jakub Narebski
2007-06-17 15:39 ` Sven Verdoolaege

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