Skip to content

Commit

Permalink
switch to Test::More, done_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jun 1, 2022
1 parent 2563c97 commit 4c69f91
Show file tree
Hide file tree
Showing 75 changed files with 298 additions and 454 deletions.
30 changes: 17 additions & 13 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

# Check for Time::HiRes;
eval { require Time::HiRes; };
if($@) {
print "Warning: Time::HiRes not installed, but that's ok, " .
"%r will use full seconds\n";
}

my $meta_merge = {
META_MERGE => {
"meta-spec" => { version => 2 },
resources => {
repository => 'https://github.com/mschilli/log4perl',
repository => {
type => 'git',
url => '[email protected]:github.com/mschilli/log4perl.git',
web => 'https://github.com/github.com/mschilli/log4perl',
},
MailingList => 'mailto:[email protected]',
bugtracker => {
bugtracker => {
web => 'https://github.com/mschilli/log4perl/issues',
},
},
Expand All @@ -28,6 +27,15 @@ my $meta_merge = {
'Log::Dispatch::FileRotate' => '1.10',
'XML::DOM' => '1.29',
},
requires => {
'File::Spec' => '0.82',
'File::Path' => '2.07',
},
},
test => {
requires => {
'Test::More' => '0.88', # done_testing
},
},
},
}
Expand All @@ -36,10 +44,6 @@ my $meta_merge = {
WriteMakefile(
'NAME' => 'Log::Log4perl',
'VERSION_FROM' => 'lib/Log/Log4perl.pm', # finds $VERSION
'PREREQ_PM' => { Test::More => 0.45,
File::Spec => 0.82,
File::Path => 2.07,
}, # e.g., Module::Name => 1.1
ABSTRACT_FROM => 'lib/Log/Log4perl.pm', # retrieve abstract from module
AUTHOR => 'Mike Schilli <[email protected]>',
MIN_PERL_VERSION => '5.006',
Expand Down
8 changes: 3 additions & 5 deletions t/001Level.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
# Mike Schilli, 2002 ([email protected])
###########################################

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test;
use strict;
use Test::More;

BEGIN {
if($ENV{INTERNAL_DEBUG}) {
Expand All @@ -16,7 +13,6 @@ BEGIN {
}
}

BEGIN { plan tests => 34 };
use Log::Log4perl::Level;
BEGIN {
Log::Log4perl::Level->import("Level");
Expand Down Expand Up @@ -59,3 +55,5 @@ ok(Log::Log4perl::Level::isGreaterOrEqual($My::Level::DEBUG, $My::Level::INFO));
ok(Log::Log4perl::Level::isGreaterOrEqual($My::Level::INFO, $My::Level::WARN));
ok(Log::Log4perl::Level::isGreaterOrEqual($My::Level::WARN, $My::Level::ERROR));
ok(Log::Log4perl::Level::isGreaterOrEqual($My::Level::ERROR, $My::Level::FATAL));

done_testing;
9 changes: 3 additions & 6 deletions t/002Logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ BEGIN {
}
}

use warnings;
use strict;

#########################
# used Test::Simple to help debug the test script
use Test::More tests => 74;

use warnings;
use Test::More;
use Log::Log4perl;
use Log::Log4perl::Level;
use Log::Log4perl::Util;
Expand Down Expand Up @@ -401,3 +397,4 @@ is($@, "", "Adding file appender");
eval { $log10->add_appender($app_screen); };
is($@, "", "Adding screen appender");

done_testing;
4 changes: 2 additions & 2 deletions t/003Layout-Rr.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN {
use strict;
use warnings;

use Test::More tests => 2;
use Test::More;
use File::Spec;

use Log::Log4perl;
Expand Down Expand Up @@ -86,6 +86,7 @@ is_deeply(
]
);

done_testing;

#
# Returns the elapsed times logged so far.
Expand Down Expand Up @@ -151,4 +152,3 @@ sub create_logger {

return $logger;
}

8 changes: 2 additions & 6 deletions t/003Layout.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ BEGIN {
}
}

use warnings;
use strict;
use warnings;

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More;
BEGIN { plan tests => 24 };

use Log::Log4perl;
use Log::Log4perl::Layout;

Expand Down Expand Up @@ -283,3 +278,4 @@ eval {
};
is($app->buffer(), "main::: Thats the\nmain::: multiline\nmain::: message\n");

done_testing;
5 changes: 1 addition & 4 deletions t/004Config.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More;
BEGIN { plan tests => 28 };

use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;
Expand Down Expand Up @@ -404,3 +400,4 @@ END_CONF
eval { Log::Log4perl->init( \$conf ); };
is $@, "", "support exclamation comment character [github.com #24]";

done_testing;
7 changes: 2 additions & 5 deletions t/005Config-Perl.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More;
BEGIN { plan tests => 3 };

use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;
use File::Spec;
Expand Down Expand Up @@ -56,3 +51,5 @@ $logger->debug("Gurgel");
$data = <LOG>;

is($data, "005Config-Perl.t $line DEBUG N/A - Gurgel\n");

done_testing;
5 changes: 2 additions & 3 deletions t/006Config-Java.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More;

our $LOG_DISPATCH_PRESENT = 0;
Expand Down Expand Up @@ -72,3 +69,5 @@ $data =~ s#\\#/#g;

unlink $LOGFILE;
is($data, "$exp");

done_testing;
12 changes: 4 additions & 8 deletions t/007LogPrio.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test;
BEGIN { plan tests => 2 };


use Test::More;
use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;
use File::Spec;
Expand Down Expand Up @@ -64,4 +58,6 @@ $file $lines[4] FATAL N/A - Gurgel
EOT

unlink $LOGFILE;
ok($data, "$exp");
is($data, $exp);

done_testing;
17 changes: 7 additions & 10 deletions t/008ConfCat.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test;
BEGIN { plan tests => 3 };

use Test::More;
use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;

Expand All @@ -37,8 +32,8 @@ Log::Log4perl->init("$EG_DIR/log4j-manual-2.conf");
my $logger = Log::Log4perl->get_logger("foo.bar.baz");
$logger->debug("Gurgel");

ok(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
"m#$date_regex \\[N/A\\] DEBUG foo.bar.baz - Gurgel#");
like(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
qr#$date_regex \[N/A\] DEBUG foo.bar.baz - Gurgel#);

######################################################################
# Test the root logger via inheritance (discovered by Kevin Goess)
Expand All @@ -52,5 +47,7 @@ Log::Log4perl->init("$EG_DIR/log4j-manual-2.conf");
$logger = Log::Log4perl->get_logger("foo");
$logger->debug("Gurgel");

ok(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
"m#$date_regex \\[N/A\\] DEBUG foo - Gurgel#");
like(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(),
qr#$date_regex \[N/A\] DEBUG foo - Gurgel#);

done_testing;
9 changes: 3 additions & 6 deletions t/009Deuce.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test;
BEGIN { plan tests => 5 };

use Test::More;
use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;

Expand Down Expand Up @@ -53,3 +48,5 @@ ok(Log::Log4perl::Appender::TestBuffer->by_name("stdout")->buffer(),
'm#^\S+\s+\[N/A\] \(\S+?:\d+\) - Gurgel$#');
ok(Log::Log4perl::Appender::TestBuffer->by_name("R")->buffer(),
'm#^\S+\s+N/A \'foo\' - Gurgel$#');

done_testing;
2 changes: 2 additions & 0 deletions t/010JConsole.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ my $rc = is ($result, $expected);
if( !$rc ) {
warn "Failed with Log::Dispatch $Log::Dispatch::VERSION";
}

done_testing;
1 change: 1 addition & 0 deletions t/011JFile.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ EOL
is ($result, $expected);

reset_logger();
done_testing;

sub reset_logger {
local $Log::Log4perl::Config::CONFIG_INTEGRITY_CHECK = 0; # to close handles and allow temp files to go
Expand Down
1 change: 1 addition & 0 deletions t/012Deeper.t
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ foreach my $l ($xla, $xlab, $xlabc, $xlabcd, $xlabcde){
is($result, $expected);

reset_logger();
done_testing;

sub reset_logger {
local $Log::Log4perl::Config::CONFIG_INTEGRITY_CHECK = 0; # to close handles and allow temp files to go
Expand Down
16 changes: 3 additions & 13 deletions t/013Bench.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ BEGIN {
}
}

use Test;
use Test::More;
use Benchmark qw/timeit timestr/;
use Log::Log4perl;

$count = 100_000;

unless ($ENV{LOG4PERL_BENCH}) {
print "set \$ENV{LOG4PERL_BENCH} to a true value to run benchmarks, skipping...\n";
ok(1);
exit;
plan skip_all => "set \$ENV{LOG4PERL_BENCH} to a true value to run benchmarks, skipping...\n";
}

$conf = <<EOL;
Expand Down Expand Up @@ -131,14 +129,6 @@ print "same appenders, two levels of inheritance: \n";
$t = timeit $count, sub {$multi3->info('info message')};
print timestr($t),"\n\n";






print


ok(1);

BEGIN { plan tests => 1, }
done_testing;
2 changes: 1 addition & 1 deletion t/014ConfErrs.t
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ eval {
};
like($@, qr/log4perl.logger.Foo.Bar redefined/);

BEGIN { plan tests => 14, }
done_testing;
7 changes: 3 additions & 4 deletions t/015fltmsg.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ BEGIN {
}
}

#########################
# change 'tests => 1' to 'tests => last_test_to_print';
#########################
use Test::More tests => 5;
use Test::More;

use Log::Log4perl;
use Log::Log4perl::Appender::TestBuffer;
Expand Down Expand Up @@ -118,3 +115,5 @@ $logger->debug("Chunk1", "Chunk2", "Chunk3");

is($app->buffer(), "[1,Chunk1,Chunk2,Chunk3]",
"warp_message = function (by name)");

done_testing;
Loading

0 comments on commit 4c69f91

Please sign in to comment.