git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: Fix "Use of uninitialized value" warning in git_tags_body
Date: Wed, 03 Jan 2007 23:11:53 +0100	[thread overview]
Message-ID: <enh9h8$7l0$2@sea.gmane.org> (raw)
In-Reply-To: 11678612691404-git-send-email-jnareb@gmail.com

Jakub Narebski wrote:

> Fix "Use of uninitialized value" warning in git_tags_body generated
> for lightweight tags of tree and blob object; those don't have age
> ($tag{'age'}) defined.

By the way, the latest "Fix warnings" patches for gitweb were result
of working on bare bones test suite for gitweb. For now I'm only
checking if there was anything written to STDERR.

BTW how in portable way to check that given file matches given patterns
in specified order, or matches given patterns in any order?

Below current version of script.

#!/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 does not spew any errors
or warnings.'

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 = "";
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

        rm -f gitweb.log &&
        perl -- $(pwd)/../../gitweb/gitweb.perl \
                >/dev/null 2>gitweb.log &&
        test ! -s gitweb.log
}

. ./test-lib.sh

gitweb_init

#test_debug 'cat $(pwd)/gitweb_config.perl'

# ----------------------------------------------------------------------
# no commits

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)' \
        'gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
        'no commits: .git tree (implicit)' \
        'gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

test_expect_success \
        'no commits: .git heads (implicit)' \
        'gitweb_run "p=.git;a=heads"'
test_debug 'cat gitweb.log'

test_expect_success \
        'no commits: .git tags (implicit)' \
        '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."'

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)' \
        'gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
        '.git commitdiff (implicit)' \
        'gitweb_run "p=.git;a=commitdiff"'
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 commit (..invalid^..)' \
        'gitweb_run "p=.git;a=commit;h=..invalid^.."'
test_debug 'cat gitweb.log'

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 tree (implicit)' \
        'gitweb_run "p=.git;a=tree"'
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 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'

test_expect_success \
        '.git blob (non-existent)' \
        'gitweb_run "p=.git;a=blob;f=non-existent"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# commitdiff testing

test_expect_success \
        'commitdiff: root' \
        'gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
        'commitdiff: 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: 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: 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: 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: 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: 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: 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: 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: 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'

# ----------------------------------------------------------------------
# tags testing

test_expect_success \
        'tags: different types of tags' \
        'git tag -a -m "Tag commit object" tag-commit 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_done

  reply	other threads:[~2007-01-03 22:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-03 21:54 [PATCH] gitweb: Fix "Use of uninitialized value" warning in git_tags_body Jakub Narebski
2007-01-03 22:11 ` Jakub Narebski [this message]
2007-01-04 20:51   ` Junio C Hamano
2007-01-07  2:40     ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='enh9h8$7l0$2@sea.gmane.org' \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).