1 package Test::Valgrind::Action;
8 Test::Valgrind::Action - Base class for Test::Valgrind actions.
16 our $VERSION = '1.13';
20 This class is the base for L<Test::Valgrind> actions.
22 Actions are called each time a tool encounter an error and decide what to do with it (for example passing or failing tests).
26 use base qw<Test::Valgrind::Component Test::Valgrind::Carp>;
30 =head2 C<< new action => $action >>
32 Creates a new action object of type C<$action> by requiring and redispatching the method call to the module named C<$action> if it contains C<'::'> or to C<Test::Valgrind::Action::$action> otherwise.
33 The class represented by C<$action> must inherit this class.
39 $class = ref($class) || $class;
43 if ($class eq __PACKAGE__) {
44 my $action = delete $args{action} || 'Test';
45 $action =~ s/[^\w:]//g;
46 $action = __PACKAGE__ . "::$action" if $action !~ /::/;
47 $class->_croak("Couldn't load action $action: $@")
48 unless eval "require $action; 1";
49 return $action->new(%args);
52 $class->SUPER::new(@_);
55 =head2 C<do_suppressions>
57 Indicates if the action wants C<valgrind> to run in suppression-generating mode or in analysis mode.
61 sub do_suppressions { 0 }
63 =head2 C<start $session>
65 Called when the C<$session> starts.
67 Defaults to set L<Test::Valgrind::Component/started>.
69 =head2 C<report $session, $report>
71 Invoked each time the C<valgrind> process attached to the C<$session> spots an error.
72 C<$report> is a L<Test::Valgrind::Report> object describing the error.
74 Defaults to check L<Test::Valgrind::Component/started>.
81 $self->_croak('Action isn\'t started') unless $self->started;
86 =head2 C<abort $session, $msg>
88 Triggered when the C<$session> has to interrupt the action.
94 sub abort { $_[0]->_croak($_[2]) }
96 =head2 C<finish $session>
98 Called when the C<$session> finishes.
100 Defaults to clear L<Test::Valgrind::Component/started>.
102 =head2 C<status $session>
104 Returns the status code corresponding to the last run of the action.
109 my ($self, $sess) = @_;
111 my $started = $self->started;
113 $self->_croak("Action was never started") unless defined $started;
114 $self->_croak("Action is still running") if $started;
121 L<Test::Valgrind>, L<Test::Valgrind::Component>, L<Test::Valgrind::Session>.
125 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
127 You can contact me by mail or on C<irc.perl.org> (vincent).
131 Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
132 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
136 You can find documentation for this module with the perldoc command.
138 perldoc Test::Valgrind::Action
140 =head1 COPYRIGHT & LICENSE
142 Copyright 2009,2010,2011 Vincent Pit, all rights reserved.
144 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
148 1; # End of Test::Valgrind::Action