1TAP::Parser::SourceHandUlseerr::CEoxnetcruitbaubtleedT(A3PP)e:r:lPaDrosceurm:e:nStoautricoenHandler::Executable(3)
2
3
4
6 TAP::Parser::SourceHandler::Executable - Stream output from an
7 executable TAP source
8
10 Version 3.28
11
13 use TAP::Parser::Source;
14 use TAP::Parser::SourceHandler::Executable;
15
16 my $source = TAP::Parser::Source->new->raw(['/usr/bin/ruby', 'mytest.rb']);
17 $source->assemble_meta;
18
19 my $class = 'TAP::Parser::SourceHandler::Executable';
20 my $vote = $class->can_handle( $source );
21 my $iter = $class->make_iterator( $source );
22
24 This is an executable TAP::Parser::SourceHandler - it has 2 jobs:
25
26 1. Figure out if the TAP::Parser::Source it's given is an executable
27 command ("can_handle").
28
29 2. Creates an iterator for executable commands ("make_iterator").
30
31 Unless you're writing a plugin or subclassing TAP::Parser, you probably
32 won't need to use this module directly.
33
35 Class Methods
36 "can_handle"
37
38 my $vote = $class->can_handle( $source );
39
40 Only votes if $source looks like an executable file. Casts the
41 following votes:
42
43 0.9 if it's a hash with an 'exec' key
44 0.8 if it's a .bat file
45 0.75 if it's got an execute bit set
46
47 "make_iterator"
48
49 my $iterator = $class->make_iterator( $source );
50
51 Returns a new TAP::Parser::Iterator::Process for the source.
52 "$source->raw" must be in one of the following forms:
53
54 { exec => [ @exec ] }
55
56 [ @exec ]
57
58 $file
59
60 "croak"s on error.
61
62 "iterator_class"
63
64 The class of iterator to use, override if you're sub-classing.
65 Defaults to TAP::Parser::Iterator::Process.
66
68 Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
69
70 Example
71 package MyRubySourceHandler;
72
73 use strict;
74 use vars '@ISA';
75
76 use Carp qw( croak );
77 use TAP::Parser::SourceHandler::Executable;
78
79 @ISA = qw( TAP::Parser::SourceHandler::Executable );
80
81 # expect $handler->(['mytest.rb', 'cmdline', 'args']);
82 sub make_iterator {
83 my ($self, $source) = @_;
84 my @test_args = @{ $source->test_args };
85 my $rb_file = $test_args[0];
86 croak("error: Ruby file '$rb_file' not found!") unless (-f $rb_file);
87 return $self->SUPER::raw_source(['/usr/bin/ruby', @test_args]);
88 }
89
91 TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory,
92 TAP::Parser::SourceHandler, TAP::Parser::SourceHandler::Perl,
93 TAP::Parser::SourceHandler::File, TAP::Parser::SourceHandler::Handle,
94 TAP::Parser::SourceHandler::RawTAP
95
96
97
98perl v5.16.3 2013T-A0P5:-:0P2arser::SourceHandler::Executable(3)