From: Vincent Pit Date: Wed, 24 Feb 2010 14:36:58 +0000 (+0100) Subject: Revamp t/92-pod-coverage.t X-Git-Tag: v0.07~15 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=commitdiff_plain;h=cb9eb6a59510dcfb9aaf05e09d2612aa0a9e18e3 Revamp t/92-pod-coverage.t Also rename some App::Rgit::Policy features and expand POD. --- diff --git a/bin/rgit b/bin/rgit index 1ee1158..ef98852 100755 --- a/bin/rgit +++ b/bin/rgit @@ -36,10 +36,10 @@ if (-t && $opts{I}) { } elsif ($opts{K}) { $policy = 'Keep'; } -$policy = eval { App::Rgit::Policy->new(name => $policy) }; +$policy = eval { App::Rgit::Policy->new(policy => $policy) }; if (not defined $policy) { print STDERR $@ if $@; - $policy = App::Rgit::Policy->new(name => 'Default'); + $policy = App::Rgit::Policy->new(policy => 'Default'); } setpgrp 0, 0 if $Config{d_setpgrp}; diff --git a/lib/App/Rgit/Command.pm b/lib/App/Rgit/Command.pm index fa98b6e..a873b9a 100644 --- a/lib/App/Rgit/Command.pm +++ b/lib/App/Rgit/Command.pm @@ -94,7 +94,7 @@ Returns what policy C method returned, which should be one of the policy sub report { my ($self) = @_; - my $code = $self->policy->report(@_); + my $code = $self->policy->handle(@_); return defined $code ? $code : NEXT; } diff --git a/lib/App/Rgit/Command/Each.pm b/lib/App/Rgit/Command/Each.pm index 9cf0067..3f1948c 100644 --- a/lib/App/Rgit/Command/Each.pm +++ b/lib/App/Rgit/Command/Each.pm @@ -59,6 +59,8 @@ sub run { L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/lib/App/Rgit/Command/Once.pm b/lib/App/Rgit/Command/Once.pm index cf5a686..084cd14 100644 --- a/lib/App/Rgit/Command/Once.pm +++ b/lib/App/Rgit/Command/Once.pm @@ -42,6 +42,8 @@ sub run { L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/lib/App/Rgit/Config/Default.pm b/lib/App/Rgit/Config/Default.pm index cd2160b..fc3152a 100644 --- a/lib/App/Rgit/Config/Default.pm +++ b/lib/App/Rgit/Config/Default.pm @@ -60,6 +60,8 @@ sub repos { L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/lib/App/Rgit/Policy.pm b/lib/App/Rgit/Policy.pm index dfd4856..2a0c760 100644 --- a/lib/App/Rgit/Policy.pm +++ b/lib/App/Rgit/Policy.pm @@ -15,6 +15,21 @@ Version 0.06 our $VERSION = '0.06'; +=head1 DESCRIPTION + +Base class for L policies. + +This is an internal class to L. + +=head1 METHODS + +=head2 C<< new policy => $policy >> + +Creates a new policy object of type C<$policy> by requiring and redispatching the method call to the module named C<$policy> if it contains C<'::'> or to C otherwise. +The class represented by C<$policy> must inherit this class. + +=cut + sub new { my $class = shift; $class = ref $class || $class; @@ -22,7 +37,7 @@ sub new { my %args = @_; if ($class eq __PACKAGE__) { - my $policy = delete $args{name}; + my $policy = delete $args{policy}; $policy = 'Default' unless defined $policy; $policy = __PACKAGE__ . "::$policy" unless $policy =~ /::/; eval "require $policy" or die $@; @@ -32,6 +47,16 @@ sub new { bless { }, $class; } +=head2 C + +Make the policy handle the end of execution of the L object C<$cmd> with L configuration C<$config> in the L repository C<$repo> that exited with status C<$status> and maybe received signal C<$sigal>. + +This method must be implemented when subclassing. + +=cut + +sub handle; + =head1 SEE ALSO L. diff --git a/lib/App/Rgit/Policy/Default.pm b/lib/App/Rgit/Policy/Default.pm index d8d286b..5d96a66 100644 --- a/lib/App/Rgit/Policy/Default.pm +++ b/lib/App/Rgit/Policy/Default.pm @@ -19,7 +19,22 @@ Version 0.06 our $VERSION = '0.06'; -sub report { +=head1 DESCRIPTION + +This is the default policy. +It stops as soon as a run returned a non-zero status, but continues if it was signalled. + +=head1 METHODS + +This class inherits from L. + +It implements : + +=head2 C + +=cut + +sub handle { my ($policy, $cmd, $conf, $repo, $status, $signal) = @_; $status ? LAST : NEXT; @@ -29,6 +44,8 @@ sub report { L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/lib/App/Rgit/Policy/Interactive.pm b/lib/App/Rgit/Policy/Interactive.pm index f6f20b5..fd4d9df 100644 --- a/lib/App/Rgit/Policy/Interactive.pm +++ b/lib/App/Rgit/Policy/Interactive.pm @@ -21,6 +21,23 @@ Version 0.06 our $VERSION = '0.06'; +=head1 DESCRIPTION + +When a run exited with non-zero status, this policy asks the user whether he wants to ignore and continue with the next repository, ignore all future possible errors, retry this run or open a shell in the current repository. +In this last case, the user will be asked again what to do when he will close the shell. + +=head1 METHODS + +This class inherits from L. + +It implements : + +=head2 C + +The constructor will die if L can't be loaded. + +=cut + my ($int_code, $shell); sub new { @@ -46,6 +63,10 @@ sub new { $class->SUPER::new(@_); } +=head2 C + +=cut + my %codes = ( 'a' => [ LAST, 'aborting' ], 'i' => [ NEXT, 'ignoring' ], @@ -53,7 +74,7 @@ my %codes = ( 'r' => [ REDO, 'retrying' ], ); -sub report { +sub handle { my ($policy, $cmd, $conf, $repo, $status, $signal) = @_; return NEXT unless $status; @@ -94,6 +115,10 @@ sub report { L. +L. + +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/lib/App/Rgit/Policy/Keep.pm b/lib/App/Rgit/Policy/Keep.pm index 1bbdc56..34b8f4f 100644 --- a/lib/App/Rgit/Policy/Keep.pm +++ b/lib/App/Rgit/Policy/Keep.pm @@ -19,12 +19,28 @@ Version 0.06 our $VERSION = '0.06'; -sub report { NEXT } +=head1 DESCRIPTION + +This policy always proceed to the next repository even when an error occurs. + +=head1 METHODS + +This class inherits from L. + +It implements : + +=head2 C + +=cut + +sub handle { NEXT } =head1 SEE ALSO L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. diff --git a/t/20-each.t b/t/20-each.t index 41e679a..346f755 100644 --- a/t/20-each.t +++ b/t/20-each.t @@ -124,8 +124,8 @@ sub try { my ($fh, $filename) = tempfile(UNLINK => 1); my $policy = App::Rgit::Policy->new( - @_ > 2 ? (name => 'Callback', callback => $_[2]) - : (name => 'Default') + @_ > 2 ? (policy => 'Callback', callback => $_[2]) + : (policy => 'Default') ); my $ar = App::Rgit->new( diff --git a/t/92-pod-coverage.t b/t/92-pod-coverage.t index 3037c13..3acb46b 100644 --- a/t/92-pod-coverage.t +++ b/t/92-pod-coverage.t @@ -16,4 +16,24 @@ my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; -all_pod_coverage_ok(); +my $trustparents = { coverage_class => 'Pod::Coverage::CountParents' }; + +plan tests => 12; + +pod_coverage_ok('App::Rgit'); + +pod_coverage_ok('App::Rgit::Command'); +pod_coverage_ok('App::Rgit::Command::Each', $trustparents); +pod_coverage_ok('App::Rgit::Command::Once', $trustparents); + +pod_coverage_ok('App::Rgit::Config'); +pod_coverage_ok('App::Rgit::Config::Default', $trustparents); + +pod_coverage_ok('App::Rgit::Policy'); +pod_coverage_ok('App::Rgit::Policy::Default', $trustparents); +pod_coverage_ok('App::Rgit::Policy::Interactive', $trustparents); +pod_coverage_ok('App::Rgit::Policy::Keep', $trustparents); + +pod_coverage_ok('App::Rgit::Repository'); + +pod_coverage_ok('App::Rgit::Utils'); diff --git a/t/lib/App/Rgit/Policy/Callback.pm b/t/lib/App/Rgit/Policy/Callback.pm index 37c2764..3b6feb9 100644 --- a/t/lib/App/Rgit/Policy/Callback.pm +++ b/t/lib/App/Rgit/Policy/Callback.pm @@ -24,7 +24,7 @@ BEGIN { eval "sub $_ { \$_[0]->{$_} }" for qw/callback/; } -sub report { +sub handle { my $policy = shift; $policy->callback->(@_);