1TAP::Parser::SourceHandUlseerr::CPoenrtlr(i3b)uted PerlTDAoPc:u:mPeanrtsaetri:o:nSourceHandler::Perl(3)
2
3
4

NAME

6       TAP::Parser::SourceHandler::Perl - Stream TAP from a Perl executable
7

VERSION

9       Version 3.42
10

SYNOPSIS

12         use TAP::Parser::Source;
13         use TAP::Parser::SourceHandler::Perl;
14
15         my $source = TAP::Parser::Source->new->raw( \'script.pl' );
16         $source->assemble_meta;
17
18         my $class = 'TAP::Parser::SourceHandler::Perl';
19         my $vote  = $class->can_handle( $source );
20         my $iter  = $class->make_iterator( $source );
21

DESCRIPTION

23       This is a Perl TAP::Parser::SourceHandler - it has 2 jobs:
24
25       1. Figure out if the TAP::Parser::Source it's given is actually a Perl
26       script ("can_handle").
27
28       2. Creates an iterator for Perl sources ("make_iterator").
29
30       Unless you're writing a plugin or subclassing TAP::Parser, you probably
31       won't need to use this module directly.
32

METHODS

34   Class Methods
35       "can_handle"
36
37         my $vote = $class->can_handle( $source );
38
39       Only votes if $source looks like a file.  Casts the following votes:
40
41         0.9  if it has a shebang ala "#!...perl"
42         0.75 if it has any shebang
43         0.8  if it's a .t file
44         0.9  if it's a .pl file
45         0.75 if it's in a 't' directory
46         0.25 by default (backwards compat)
47
48       "make_iterator"
49
50         my $iterator = $class->make_iterator( $source );
51
52       Constructs & returns a new TAP::Parser::Iterator::Process for the
53       source.  Assumes "$source->raw" contains a reference to the perl
54       script.  "croak"s if the file could not be found.
55
56       The command to run is built as follows:
57
58         $perl @switches $perl_script @test_args
59
60       The perl command to use is determined by "get_perl".  The command
61       generated is guaranteed to preserve:
62
63         PERL5LIB
64         PERL5OPT
65         Taint Mode, if set in the script's shebang
66
67       Note: the command generated will not respect any shebang line defined
68       in your Perl script.  This is only a problem if you have compiled a
69       custom version of Perl or if you want to use a specific version of Perl
70       for one test and a different version for another, for example:
71
72         #!/path/to/a/custom_perl --some --args
73         #!/usr/local/perl-5.6/bin/perl -w
74
75       Currently you need to write a plugin to get around this.
76
77       "get_taint"
78
79       Decode any taint switches from a Perl shebang line.
80
81         # $taint will be 't'
82         my $taint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl -t' );
83
84         # $untaint will be undefined
85         my $untaint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl' );
86
87       "get_perl"
88
89       Gets the version of Perl currently running the test suite.
90

SUBCLASSING

92       Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
93
94   Example
95         package MyPerlSourceHandler;
96
97         use strict;
98
99         use TAP::Parser::SourceHandler::Perl;
100
101         use base 'TAP::Parser::SourceHandler::Perl';
102
103         # use the version of perl from the shebang line in the test file
104         sub get_perl {
105             my $self = shift;
106             if (my $shebang = $self->shebang( $self->{file} )) {
107                 $shebang =~ /^#!(.*\bperl.*?)(?:(?:\s)|(?:$))/;
108                 return $1 if $1;
109             }
110             return $self->SUPER::get_perl(@_);
111         }
112

SEE ALSO

114       TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory,
115       TAP::Parser::SourceHandler, TAP::Parser::SourceHandler::Executable,
116       TAP::Parser::SourceHandler::File, TAP::Parser::SourceHandler::Handle,
117       TAP::Parser::SourceHandler::RawTAP
118
119
120
121perl v5.26.3                      2018-03-19TAP::Parser::SourceHandler::Perl(3)
Impressum