From: Kevin G. <ke...@go...> - 2002-09-23 16:55:37
|
> I've removed all but one instance of POPULATION[x] > in the test cases, t/027Watch.t seems to need access to the latest > created appender, so I left that > one in. Kevin, can you please double-check? Reloading the config file pushed a new appender into @POPULATION with the same name as the old one, so I changed @POPULATION to a hash so we can do lookups by name, which seemed to be where you were going with it anyway. Diff is below, already checked in, all tests pass, that ok with you? =================================================================== RCS file: /cvsroot/log4perl/Log-Log4perl/lib/Log/Log4perl/TestBuffer.pm,v retrieving revision 1.3 diff -u -r1.3 TestBuffer.pm --- modules/TestBuffer.pm 22 Sep 2002 18:37:17 -0000 1.3 +++ modules/TestBuffer.pm 23 Sep 2002 16:43:16 -0000 @@ -10,17 +10,7 @@ use base qw( Log::Dispatch::Output ); use fields qw( stderr ); - # This is a dirty trick for testing: Keep track - # of the entire object population. So we'll - # be able to access the buffers even if the - # objects are created behind our back -- as - # long as we remember the order in which - # they've been created: - # $Log::Log4perl::TestBuffer::POPULATION[0] is - # the first one etc. - # The DESTROY method below cleans up afterwards. - -our @POPULATION = (); +our %POPULATION = (); ################################################## sub new { @@ -35,7 +25,7 @@ $self->{stderr} = exists $params{stderr} ? $params{stderr} : 1; $self->{buffer} = ""; - push @POPULATION, $self; + $POPULATION{$self->name} = $self; return $self; } @@ -66,7 +56,7 @@ ################################################## my($self) = @_; - @POPULATION = (); + %POPULATION = (); $self->{buffer} = ""; } @@ -77,7 +67,7 @@ return unless defined $self; - @POPULATION = grep { defined $_ && $_ != $self } @POPULATION; + delete $POPULATION{$self->name}; } ################################################## @@ -92,12 +82,8 @@ die "No name given" unless defined $name; - for my $appender (@POPULATION) { - if($appender->name() eq $name) { - return $appender; - } - } - return undef; + return $POPULATION{$name}; + } Mike Schilli wrote: > Hi all, > > just found out that with the latest perl 5.8.0, one of the test cases utilizing POPULATION[x] failed > because it was relying on the order of hash keys when creating the appenders via a conf file. Fixed > that by introducing a by_name() method for Log::Log4perl::TestBuffer which lets you retrieve a > TestBuffer by name (like "A1" in a config file). I've removed all but one instance of POPULATION[x] > in the test cases, t/027Watch.t seems to need access to the latest created appender, so I left that > one in. Kevin, can you please double-check? > > Everything else looks good, I guess we can release 0.24 soon. Changes so far: > > * (kg) Fix for init_and_watch and test cases > * (ms) Added documentation for Log::Log4perl::Config > * (ms) Added log4perl.additivity.loggerName conf file syntax > * (ms) Assume Log::Log4perl::Layout prefix of 'relative' > layout class names in conf file (say 'SimpleLayout' > instead of 'Log::Log4perl::Layout::SimpleLayout'). > * (ms) accidently appending a ';' at the end of an appender > class in a conf file now spits out a reasonable error message > * (ms) added a by_name() method to TestBuffer to retrieve an > instance of the TestBuffer population by name instead of > relying on the order of creation via POPULATION[x] > (for testing only). > > Any comments/problems, please let me know. > > -- Mike > -------------------------------------------------------- > Mike Schilli log...@pe... http://perlmeister.com > -------------------------------------------------------- > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |