Subject: Re: [PATCH] gitweb: Fix "Use of uninitialized value" warning in git_tags_body

From: Jakub Narebski <[email-masked]>
Date: Sun, 7 Jan 2007 03:40:00 +0100

Junio C Hamano wrote:
> Jakub Narebski <[email-masked]> writes:
> 
>>> 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.
> 
> I think this is a useful thing to have in-tree at this point,
> with perhaps minor tweaks I'd suggest later.  That way other
> people can write more tests to catch regressions.

I plan to submit it soonish... should I submit it early, incomplete,
or first fix it up a bit?

>> BTW how in portable way to check that given file matches given patterns
>> in specified order, or matches given patterns in any order?
> 
> This depends on how different the same page is rendered at
> different times; I suspect the outputs for the same request from
> two runs of the test are expected to be different in age, commit
> and tag object ID and nothing else?

The problem with test for gitweb is that is fairly easy to test
for things that should not change independent of the changes in
output, namely:
 * gitweb should not write warnings and errors to web server log,
   if they result from incorrect parameters (e.g. object not found);
   simple check if anything is written to STDERR
 * the output should be well-formed XHTML (or XML in the case
   of OPML, RSS and Atom fields), but this needs externel tools
   like HTMLtidy
 * HTTP status is well defined, too
 
What is harder to check is that:
 * all the information which should be is there

The goal is to have test which does not change from pass to fail
if we replace ' ' by '&nbsp;', make some fragment hyperlink,
add something, etc...

> If so, I think using test_tick() to force the stable commit
> object ID while your test is building a test repository would be
> a useful thing to do.  Also I think replacing call to "time"
> (you seem to call it from multiple places, all to compute "age")
> with a call to a subroutine "git_time" and then defining:
> 
> 	sub git_time {
>         	if (exists $::ENV{GIT_TEST_TIME}) {
>                 	return $::ENV{GIT_TEST_TIME};
>                 }
>                 return time;
>         }
> 
> to help testing would be sensible.  Set and export GIT_TEST_TIME
> to a fixed time (say, midnight GMT December 28th, 2006) in
> gitweb_init and you will get stable agestring if you have
> already made the commit and author timestamps stable with
> test_tick().

Good idea, nice to know. Even nicer would be to have it described
in t/README...

-- 
Jakub Narebski
Poland