X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FCommand%2FPerlScript.pm;h=99ff387fa99dffe518742033998a00fc1cff29a0;hb=b34179155630f5f4cbea1749af4054a746ded9a4;hp=a107b7992e2cf69f65b955eac4e440716d2667e2;hpb=3968e3b9715c8e5e7eaf998012d434b914b9e126;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Command/PerlScript.pm b/lib/Test/Valgrind/Command/PerlScript.pm index a107b79..99ff387 100644 --- a/lib/Test/Valgrind/Command/PerlScript.pm +++ b/lib/Test/Valgrind/Command/PerlScript.pm @@ -9,11 +9,11 @@ Test::Valgrind::Command::PerlScript - A Test::Valgrind command that invokes a pe =head1 VERSION -Version 1.00 +Version 1.17 =cut -our $VERSION = '1.00'; +our $VERSION = '1.17'; =head1 DESCRIPTION @@ -21,20 +21,35 @@ This command is meant to abstract the argument list handling of a C script =cut -use base qw/Test::Valgrind::Command::Perl Test::Valgrind::Carp/; +use base qw; =head1 METHODS This class inherits L. -=head2 C<< new file => $file, [ taint_mode => $taint_mode ], ... >> +=head2 C -Your usual constructor. + my $tvcps = Test::Valgrind::Command::PerlScript->new( + file => $file, + taint_mode => $taint_mode, + %extra_args, + ); + +The package constructor, which takes several options : + +=over 4 + +=item * C<$file> is the path to the C script you want to run. -C<$taint_mode> is a boolean that specifies if the script should be run under taint mode. -If C is passed (which is the default), the constructor will try to infer it from the shebang line of the script. +This option is mandatory. + +=item * + +C<$taint_mode> is actually handled by the parent class L, but it gets special handling in this subclass : if C is passed (which is the default), the constructor will try to infer its right value from the shebang line of the script. + +=back Other arguments are passed straight to C<< Test::Valgrind::Command::Perl->new >>. @@ -46,14 +61,10 @@ sub new { my %args = @_; - my $file = delete $args{file}; + my $file = delete $args{file}; $class->_croak('Invalid script file') unless $file and -e $file; - my $taint_mode = delete $args{taint_mode}; - - my $self = bless $class->SUPER::new(%args), $class; - - $self->{file} = $file; + my $taint_mode = delete $args{taint_mode}; if (not defined $taint_mode and open my $fh, '<', $file) { my $first = <$fh>; close $fh; @@ -62,7 +73,13 @@ sub new { } $taint_mode = 0 unless defined $taint_mode; } - $self->{taint_mode} = $taint_mode; + + my $self = bless $class->SUPER::new( + taint_mode => $taint_mode, + %args, + ), $class; + + $self->{file} = $file; return $self; } @@ -71,21 +88,18 @@ sub new_trainer { Test::Valgrind::Command::Perl->new_trainer } =head2 C -Read-only accessor for the C option. - -=head2 C + my $file = $tvcps->file; -Read-only accessor for the C option. +Read-only accessor for the C option. =cut -eval "sub $_ { \$_[0]->{$_} }" for qw/file taint_mode/; +sub file { $_[0]->{file} } sub args { my $self = shift; return $self->SUPER::args(@_), - (('-T') x!! $self->taint_mode), $self->file } @@ -112,7 +126,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2009 Vincent Pit, all rights reserved. +Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.