1TAP::Parser::Source::PerPle(r3lpmP)rogrammers ReferenceTAGPu:i:dPearser::Source::Perl(3pm)
2
3
4

NAME

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

VERSION

9       Version 3.17
10

SYNOPSIS

12         use TAP::Parser::Source::Perl;
13         my $perl = TAP::Parser::Source::Perl->new;
14         my $stream = $perl->source( [ $filename, @args ] )->get_stream;
15

DESCRIPTION

17       Takes a filename and hopefully returns a stream from it.  The filename
18       should be the name of a Perl program.
19
20       Note that this is a subclass of TAP::Parser::Source.  See that module
21       for more methods.
22

METHODS

24   Class Methods
25       "new"
26
27        my $perl = TAP::Parser::Source::Perl->new;
28
29       Returns a new "TAP::Parser::Source::Perl" object.
30
31   Instance Methods
32       "source"
33
34       Getter/setter the name of the test program and any arguments it
35       requires.
36
37         my ($filename, @args) = @{ $perl->source };
38         $perl->source( [ $filename, @args ] );
39
40       "croak"s if $filename could not be found.
41
42       "switches"
43
44         my $switches = $perl->switches;
45         my @switches = $perl->switches;
46         $perl->switches( \@switches );
47
48       Getter/setter for the additional switches to pass to the perl
49       executable.  One common switch would be to set an include directory:
50
51         $perl->switches( ['-Ilib'] );
52
53       "get_stream"
54
55         my $stream = $source->get_stream($parser);
56
57       Returns a stream of the output generated by executing "source". Must be
58       passed an object that implements a "make_iterator" method. Typically
59       this is a TAP::Parser instance.
60
61       "shebang"
62
63       Get the shebang line for a script file.
64
65         my $shebang = TAP::Parser::Source::Perl->shebang( $some_script );
66
67       May be called as a class method
68
69       "get_taint"
70
71       Decode any taint switches from a Perl shebang line.
72
73         # $taint will be 't'
74         my $taint = TAP::Parser::Source::Perl->get_taint( '#!/usr/bin/perl -t' );
75
76         # $untaint will be undefined
77         my $untaint = TAP::Parser::Source::Perl->get_taint( '#!/usr/bin/perl' );
78

SUBCLASSING

80       Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
81
82   Example
83         package MyPerlSource;
84
85         use strict;
86         use vars '@ISA';
87
88         use Carp qw( croak );
89         use TAP::Parser::Source::Perl;
90
91         @ISA = qw( TAP::Parser::Source::Perl );
92
93         sub source {
94             my ($self, $args) = @_;
95             if ($args) {
96                 $self->{file} = $args->[0];
97                 return $self->SUPER::source($args);
98             }
99             return $self->SUPER::source;
100         }
101
102         # use the version of perl from the shebang line in the test file
103         sub _get_perl {
104             my $self = shift;
105             if (my $shebang = $self->shebang( $self->{file} )) {
106                 $shebang =~ /^#!(.*\bperl.*?)(?:(?:\s)|(?:$))/;
107                 return $1 if $1;
108             }
109             return $self->SUPER::_get_perl(@_);
110         }
111

SEE ALSO

113       TAP::Object, TAP::Parser, TAP::Parser::Source,
114
115
116
117perl v5.12.4                      2011-06-07    TAP::Parser::Source::Perl(3pm)
Impressum