Re: [PATCH] gitweb: Fix "Use of uninitialized value" warning in git_tags_body
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jan 4, 2007, 20:51 UTC
- Message-ID
- <7vsleqjz1u.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <enh9h8$7l0$2@sea.gmane.org>
Jakub Narebski <jnareb@gmail.com> writes:
Show 7 quoted lines
>> 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.
> 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?
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().