Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

Tools

TAP::Parser::Source::Perl

Perl 5 version 10.1 documentation
Recently read

TAP::Parser::Source::Perl

NAME

TAP::Parser::Source::Perl - Stream Perl output

VERSION

Version 3.17

SYNOPSIS

  1. use TAP::Parser::Source::Perl;
  2. my $perl = TAP::Parser::Source::Perl->new;
  3. my $stream = $perl->source( [ $filename, @args ] )->get_stream;

DESCRIPTION

Takes a filename and hopefully returns a stream from it. The filename should be the name of a Perl program.

Note that this is a subclass of TAP::Parser::Source. See that module for more methods.

METHODS

Class Methods

new

  1. my $perl = TAP::Parser::Source::Perl->new;

Returns a new TAP::Parser::Source::Perl object.

Instance Methods

source

Getter/setter the name of the test program and any arguments it requires.

  1. my ($filename, @args) = @{ $perl->source };
  2. $perl->source( [ $filename, @args ] );

croak s if $filename could not be found.

switches

  1. my $switches = $perl->switches;
  2. my @switches = $perl->switches;
  3. $perl->switches( \@switches );

Getter/setter for the additional switches to pass to the perl executable. One common switch would be to set an include directory:

  1. $perl->switches( ['-Ilib'] );

get_stream

  1. my $stream = $source->get_stream($parser);

Returns a stream of the output generated by executing source . Must be passed an object that implements a make_iterator method. Typically this is a TAP::Parser instance.

shebang

Get the shebang line for a script file.

  1. my $shebang = TAP::Parser::Source::Perl->shebang( $some_script );

May be called as a class method

get_taint

Decode any taint switches from a Perl shebang line.

  1. # $taint will be 't'
  2. my $taint = TAP::Parser::Source::Perl->get_taint( '#!/usr/bin/perl -t' );
  3. # $untaint will be undefined
  4. my $untaint = TAP::Parser::Source::Perl->get_taint( '#!/usr/bin/perl' );

SUBCLASSING

Please see SUBCLASSING in TAP::Parser for a subclassing overview.

Example

  1. package MyPerlSource;
  2. use strict;
  3. use vars '@ISA';
  4. use Carp qw( croak );
  5. use TAP::Parser::Source::Perl;
  6. @ISA = qw( TAP::Parser::Source::Perl );
  7. sub source {
  8. my ($self, $args) = @_;
  9. if ($args) {
  10. $self->{file} = $args->[0];
  11. return $self->SUPER::source($args);
  12. }
  13. return $self->SUPER::source;
  14. }
  15. # use the version of perl from the shebang line in the test file
  16. sub _get_perl {
  17. my $self = shift;
  18. if (my $shebang = $self->shebang( $self->{file} )) {
  19. $shebang =~ /^#!(.*\bperl.*?)(?:(?:\s)|(?:$))/;
  20. return $1 if $1;
  21. }
  22. return $self->SUPER::_get_perl(@_);
  23. }

SEE ALSO

TAP::Object, TAP::Parser, TAP::Parser::Source,