[Catalyst-commits] r9784 - in Catalyst-Runtime/5.80/trunk: . t

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Apr 21 23:12:16 GMT 2009


Author: t0m
Date: 2009-04-22 00:12:16 +0100 (Wed, 22 Apr 2009)
New Revision: 9784

Modified:
   Catalyst-Runtime/5.80/trunk/Makefile.PL
   Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t
   Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
Log:
That can't work as you get circular deps..

Modified: Catalyst-Runtime/5.80/trunk/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/trunk/Makefile.PL	2009-04-21 23:08:17 UTC (rev 9783)
+++ Catalyst-Runtime/5.80/trunk/Makefile.PL	2009-04-21 23:12:16 UTC (rev 9784)
@@ -40,22 +40,6 @@
 test_requires 'Class::Data::Inheritable';
 test_requires 'Test::MockObject';
 
-# NOTE - This is the version number which the user must upgrade to to be ok,
-my %conflicts = (
-    'Catalyst::Plugin::ConfigLoader'   => '0.23', # Older versions work but
-                                                  # throw Data::Visitor warns
-    'Catalyst::Devel'                  => '0.10',
-    'Catalyst::Plugin::SmartURI'       => '0.030',
-    'CatalystX::CRUD'                  => '0.38',
-    'Catalyst::Action::RenderView'     => '0.08',
-    'Catalyst::Plugin::DebugCookie'    => '0.999003',
-    'Catalyst::Plugin::Authentication' => '0.100092',
-    'CatalystX::Imports'               => '0.04',
-    'Catalyst::Plugin::HashedCookies'  => '1.04',
-    'Catalyst::Action::REST'           => '0.68',
-);
-check_conflicts(%conflicts);
-
 # Run aggregate tests if AGGREGATE_TESTS environment = 1, but not if it = 0
 # Otherwise default to using Test::Aggregate if installed, but not requiring it.
 if (   ( exists $ENV{AGGREGATE_TESTS} && !$ENV{AGGREGATE_TESTS})
@@ -89,12 +73,8 @@
 
   # Strip out the author only build_requires from META.yml
   # Need to do this _after_ WriteAll else it looses track of them
-  strip_build_requires(@force_build_requires_if_author);
+  strip_author_only_build_requires(@force_build_requires_if_author);
 
-  # Strip out any conflicts, so that even if the author has a conflicting
-  # module installed, we don't end up with META.fail
-  strip_requires(keys %conflicts);
-
   Meta->{values}{resources} = [
     [ 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst' ],
     [ 'IRC'         => 'irc://irc.perl.org/#catalyst' ],
@@ -124,6 +104,23 @@
  Have fun!
 EOF
 
+# NOTE - This is the version number of the _incompatible_ code,
+#        not the version number of the fixed version.
+my %conflicts = (
+    'Catalyst::Plugin::ConfigLoader'   => '0.22', # Older versions work but
+                                                  # throw Data::Visitor warns
+    'Catalyst::Devel'                  => '0.09',
+    'Catalyst::Plugin::SmartURI'       => '0.029',
+    'CatalystX::CRUD'                  => '0.37',
+    'Catalyst::Action::RenderView'     => '0.07',
+    'Catalyst::Plugin::DebugCookie'    => '0.999002',
+    'Catalyst::Plugin::Authentication' => '0.100091',
+    'CatalystX::Imports'               => '0.03',
+    'Catalyst::Plugin::HashedCookies'  => '1.03',
+    'Catalyst::Action::REST'           => '0.67',
+);
+check_conflicts(%conflicts);
+
 # End of script, helper functions below.
 
 sub darwin_check_no_resource_forks {
@@ -141,24 +138,18 @@
         }
 }
 
-sub strip_build_requires {
-    _strip_a_requires('build_requires', @_);
-}
-sub strip_requires {
-    _strip_a_requires('requires', @_);
-}
-sub _strip_a_requires {
-    my ($type, @to_strip) = @_;
-    Meta->{values}{$type} = [ grep {
+sub strip_author_only_build_requires {
+    my @build_requires_to_strip = @_;
+    Meta->{values}{build_requires} = [ grep {
       my $ok = 1;
-      foreach my $module (@to_strip) {
+      foreach my $module (@build_requires_to_strip) {
         if ($_->[0] =~ /$module/) {
           $ok = 0;
           last;
         }
       }
       $ok;
-    } @{Meta->{values}{$type}} ];
+    } @{Meta->{values}{build_requires}} ];
 }
 
 sub check_conflicts {
@@ -170,8 +161,7 @@
         next if $@;
 
         my $installed = $mod->VERSION();
-        $conflicts_found{$mod} = $installed
-            if ( $installed lt $conflicts{$mod} );
+        $conflicts_found{$mod} = $installed if ( $installed le $conflicts{$mod} );
     }
 
     return unless scalar keys %conflicts_found;
@@ -193,11 +183,11 @@
     foreach my $mod (keys %conflicts_found) {
         print sprintf("    %s => %s\n", $mod, $conflicts_found{$mod});
     }
-    print "\n\n";
-    return unless prompt("Would you like to upgrade these modules as part of this install?", 'N') =~ /Y/i;
+    print "\n";
 
-    foreach my $mod (keys %conflicts_found) {
-        requires($mod, $conflicts{$mod})
-            if prompt("Install $mod?", 'Y') =~ /Y/i;
-    }
+    # More or less copied from Module::Build, via Moose
+    return if $ENV{PERL_MM_USE_DEFAULT};
+    return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT));
+
+    sleep 4;
 }

Modified: Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t	2009-04-21 23:08:17 UTC (rev 9783)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t	2009-04-21 23:12:16 UTC (rev 9784)
@@ -2,52 +2,70 @@
 use warnings;
 use Catalyst::Runtime;
 
-use Test::More tests => 20;
+use Test::More tests => 29;
 
 {
     # Silence the log.
-    no warnings 'redefine';
-    *Catalyst::Log::_send_to_log = sub {};
+    my $meta = Catalyst::Log->meta;
+    $meta->make_mutable;
+    $meta->remove_method('_send_to_log');
+    $meta->add_method('_send_to_log', sub {});
 }
 
-TESTDEBUG: {
-    package MyTestDebug;
-    use base qw/Catalyst/;
-    __PACKAGE__->setup(
-        '-Debug',
-    );
+sub build_test_app_with_setup {
+    my ($name, @flags) = @_;
+    my $flags = '(' . join(', ', map { "'".$_."'" } @flags) . ')';
+    $flags = '' if $flags eq '()';
+    eval qq{
+        package $name;
+        use Catalyst $flags;
+        $name->setup;
+    };
+    die $@ if $@;
+    return $name;
 }
 
-ok my $c = MyTestDebug->new, 'Get debug app object';
-ok my $log = $c->log, 'Get log object';
-isa_ok $log,        'Catalyst::Log', 'It should be a Catalyst::Log object';
-ok !$log->is_warn,  'Warnings should be disabled';
-ok !$log->is_error, 'Errors should be disabled';
-ok !$log->is_fatal, 'Fatal errors should be disabled';
-ok !$log->is_info,  'Info should be disabled';
-ok $log->is_debug,  'Debugging should be enabled';
-can_ok 'MyTestDebug', 'debug';
-ok +MyTestDebug->debug, 'And it should return true';
+{
+    my $app = build_test_app_with_setup('MyTestDebug', '-Debug');
 
+    ok my $c = MyTestDebug->new, 'Get debug app object';
+    ok my $log = $c->log, 'Get log object';
+    isa_ok $log, 'Catalyst::Log', 'It should be a Catalyst::Log object';
+    ok !$log->is_warn, 'Warnings should be disabled';
+    ok !$log->is_error, 'Errors should be disabled';
+    ok !$log->is_fatal, 'Fatal errors should be disabled';
+    ok !$log->is_info, 'Info should be disabled';
+    ok $log->is_debug, 'Debugging should be enabled';
+    ok $app->debug, 'debug method should return true';
+}
 
-TESTAPP: {
-    package MyTestLog;
-    use base qw/Catalyst/;
-    __PACKAGE__->setup(
-        '-Log=warn,error,fatal'
-    );
+{
+    my $app = build_test_app_with_setup('MyTestLogParam', '-Log=warn,error,fatal');
+
+    ok my $c = $app->new, 'Get log app object';
+    ok my $log = $c->log, 'Get log object';
+    isa_ok $log, 'Catalyst::Log', 'It should be a Catalyst::Log object';
+    ok $log->is_warn, 'Warnings should be enabled';
+    ok $log->is_error, 'Errors should be enabled';
+    ok $log->is_fatal, 'Fatal errors should be enabled';
+    ok !$log->is_info, 'Info should be disabled';
+    ok !$log->is_debug, 'Debugging should be disabled';
+    ok !$c->debug, 'Catalyst debugging is off';
 }
+{
+    my $app = build_test_app_with_setup('MyTestNoParams');
 
-ok $c = MyTestLog->new, 'Get log app object';
-ok $log = $c->log, 'Get log object';
-isa_ok $log,        'Catalyst::Log', 'It should be a Catalyst::Log object';
-ok $log->is_warn,   'Warnings should be enabled';
-ok $log->is_error,  'Errors should be enabled';
-ok $log->is_fatal,  'Fatal errors should be enabled';
-ok !$log->is_info,  'Info should be disabled';
-ok !$log->is_debug, 'Debugging should be disabled';
-
-TESTOWNLOGGER: {
+    ok my $c = $app->new, 'Get log app object';
+    ok my $log = $c->log, 'Get log object';
+    isa_ok $log, 'Catalyst::Log', 'It should be a Catalyst::Log object';
+    ok $log->is_warn, 'Warnings should be enabled';
+    ok $log->is_error, 'Errors should be enabled';
+    ok $log->is_fatal, 'Fatal errors should be enabled';
+    ok $log->is_info, 'Info should be enabled';
+    ok $log->is_debug, 'Debugging should be enabled';
+    ok !$c->debug, 'Catalyst debugging turned off';
+}
+{
     package MyTestAppWithOwnLogger;
     use base qw/Catalyst/;
     use Test::MockObject;
@@ -57,5 +75,6 @@
     __PACKAGE__->setup('-Debug');
 }
 
-ok $c = MyTestAppWithOwnLogger->new, 'Get with own logger app object';
+ok my $c = MyTestAppWithOwnLogger->new, 'Get with own logger app object';
 ok $c->debug, '$c->debug is true';
+

Modified: Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t	2009-04-21 23:08:17 UTC (rev 9783)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t	2009-04-21 23:12:16 UTC (rev 9784)
@@ -73,13 +73,16 @@
     my $app = mock_app('TestLogAppEmptyString');
     $app->setup_log('');
     ok !$app->debug, 'Not In debug mode';
-    test_log_object($app->log,
-        fatal => 0,
-        error => 0,
-        warn => 0,
-        info => 0,
-        debug => 0,
-    );
+    TODO: {
+        local $TODO = 'THis is insane';
+        test_log_object($app->log,
+            fatal => 0,
+            error => 0,
+            warn => 0,
+            info => 0,
+            debug => 0,
+        );
+    }
 }
 {
     my $app = mock_app('TestLogAppDebugOnly');




More information about the Catalyst-commits mailing list