Permalink
Browse files

Test for RT#62937

Test case for RT#62937: Logger->log does not uses $DefaultLevel
synchronously
https://rt.cpan.org/Ticket/Display.html?id=62397
(filled by myself)
The test is failing with the current code (1.00), so the failing tests
are marked as TODO.
  • Loading branch information...
1 parent 0d44a1e commit f3d1f0f0db0eed1055f6981de779db81997aed43 @dolmen committed Oct 23, 2010
Showing with 63 additions and 0 deletions.
  1. +63 −0 t/60-RT62397.t
View
@@ -0,0 +1,63 @@
+# Test case for RT#62397: Logger->log does not uses $DefaultLevel synchronously
+# Author: Olivier Mengué <dolmen@cpan.org>
+
+use strict;
+use warnings;
+use Test::NoWarnings;
+use Test::More tests => 17;
+
+my @tests;
+
+BEGIN {
+ @tests = (
+ { level => error => message => '1. Error', TODO => 'Fix this race case' },
+ { level => warning => message => '2. Warning' },
+ { level => warning => message => '3. Warning' },
+ { level => error => message => '4. Error', TODO => 'Fix this race case' },
+ { level => warning => message => '5. Warning' },
+ );
+}
+
+use t::lib::Log::Dispatch::Config::Test \@tests;
+
+use POE;
+use POE::Component::Logger;
+
+POE::Component::Logger->spawn(
+ ConfigFile => t::lib::Log::Dispatch::Config::Test->configurator);
+
+is $POE::Component::Logger::DefaultLevel, 'warning', 'DefaultLevel';
+
+POE::Session->create(
+ inline_states => {
+ _start => sub {
+ pass "_start";
+ $POE::Component::Logger::DefaultLevel = 'error';
+ Logger->log('1. Error');
+ $POE::Component::Logger::DefaultLevel = 'warning';
+ Logger->log('2. Warning');
+ $poe_kernel->yield('next');
+ # Log events will be processed before 'next' as they have
+ # been laucnhed before
+ },
+ next => sub {
+ is $POE::Component::Logger::DefaultLevel, 'warning', 'DefaultLevel';
+ Logger->log('3. Warning');
+ {
+ local $POE::Component::Logger::DefaultLevel = 'error';
+ Logger->log('4. Error');
+ }
+ is $POE::Component::Logger::DefaultLevel, 'warning', 'DefaultLevel';
+ Logger->log('5. Warning');
+ },
+ _stop => sub {
+ pass "_stop";
+ },
+ },
+);
+
+POE::Kernel->run;
+
+pass "POE kernel shutdown";
+
+# vim: set et ts=4 sw=4 sts=4 :

0 comments on commit f3d1f0f

Please sign in to comment.