Test::Valgrind::Command - Base class for Test::Valgrind commands.


Test-Valgrind documentation Contained in the Test-Valgrind distribution.

Index


Code Index:

NAME

Top

Test::Valgrind::Command - Base class for Test::Valgrind commands.

VERSION

Top

Version 1.12

DESCRIPTION

Top

This class is the base for Test::Valgrind commands.

Commands gather information about the target of the analysis. They should also provide a default setup for generating suppressions.

METHODS

Top

new command => $command, args => \@args

Creates a new command object of type $command by requiring and redispatching the method call to the module named $command if it contains '::' or to Test::Valgrind::Command::$command otherwise. The class represented by $command must inherit this class.

The args key is used to initialize the args accessor.

new_trainer

Creates a new command object suitable for generating suppressions.

Defaults to return undef, which skips suppression generation.

args $session

Returns the list of command-specific arguments that are to be passed to valgrind.

Defaults to return the contents of the args option.

env $session

This event is called in scalar context before the command is ran, and the returned value goes out of scope when the analysis ends. It's useful for e.g. setting up %ENV for the child process by returning an Env::Sanctify object, hence the name.

Defaults to void.

suppressions_tag $session

Returns a identifier that will be used to pick up the right suppressions for running the command, or undef to indicate that no special suppressions are needed.

This method must be implemented when subclassing.

filter $session, $report

The $session calls this method after receiving a report from the tool and before forwarding it to the action. You can either return a mangled $report (which does not need to be a clone of the original) or undef if you want the action to ignore it completely.

Defaults to the identity function.

SEE ALSO

Top

Test::Valgrind, Test::Valgrind::Session.

AUTHOR

Top

Vincent Pit, <perl at profvince.com>, http://www.profvince.com.

You can contact me by mail or on irc.perl.org (vincent).

BUGS

Top

Please report any bugs or feature requests to bug-test-valgrind at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Test::Valgrind::Command

COPYRIGHT & LICENSE

Top


Test-Valgrind documentation Contained in the Test-Valgrind distribution.
package Test::Valgrind::Command;

use strict;
use warnings;

our $VERSION = '1.12';

use base qw/Test::Valgrind::Carp/;

sub new {
 my $class = shift;
 $class = ref($class) || $class;

 my %args = @_;

 if ($class eq __PACKAGE__ and my $cmd = delete $args{command}) {
  $cmd =~ s/[^\w:]//g;
  $cmd = __PACKAGE__ . "::$cmd" if $cmd !~ /::/;
  $class->_croak("Couldn't load command $cmd: $@") unless eval "require $cmd;1";
  return $cmd->new(%args);
 }

 my $args = delete $args{args};
 $class->_croak('Invalid argument list') if $args and ref $args ne 'ARRAY';

 bless {
  args => $args,
 }, $class;
}

sub new_trainer { }

sub args { @{$_[0]->{args} || []} }

sub env { }

sub suppressions_tag;

sub filter { $_[2] }

1; # Test::Valgrind::Command