From: Tomas Doran Date: Tue, 21 Apr 2009 23:12:16 +0000 (+0000) Subject: That can't work as you get circular deps.. X-Git-Tag: 5.80002~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d31581c60ff345e3fa71ca66bc83e826935b158b That can't work as you get circular deps.. --- diff --git a/Makefile.PL b/Makefile.PL index d877c79..c0a1454 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -40,22 +40,6 @@ recommends 'B::Hooks::OP::Check::StashChange'; 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,11 +73,7 @@ if ($Module::Install::AUTHOR) { # 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 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); + strip_author_only_build_requires(@force_build_requires_if_author); Meta->{values}{resources} = [ [ 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst' ], @@ -124,6 +104,23 @@ print <<"EOF"; 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 darwin_check_no_resource_forks { } } -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 @@ sub check_conflicts { 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 @@ EOF 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; } diff --git a/t/unit_core_setup.t b/t/unit_core_setup.t index 70b649e..bcf3030 100644 --- a/t/unit_core_setup.t +++ b/t/unit_core_setup.t @@ -2,52 +2,70 @@ use strict; 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'); -TESTAPP: { - package MyTestLog; - use base qw/Catalyst/; - __PACKAGE__->setup( - '-Log=warn,error,fatal' - ); + 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'; } -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'; +{ + my $app = build_test_app_with_setup('MyTestLogParam', '-Log=warn,error,fatal'); -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 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 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 @@ TESTOWNLOGGER: { __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'; + diff --git a/t/unit_core_setup_log.t b/t/unit_core_setup_log.t index ce4d58e..fe3e15e 100644 --- a/t/unit_core_setup_log.t +++ b/t/unit_core_setup_log.t @@ -73,13 +73,16 @@ local %ENV; # Ensure blank or someone, somewhere will fail.. 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');