| 1 | # ---------------------------------------------------------------------- copyright and license --- | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # file: lib/Dist/Zilla/Role/ProgramRunner.pm | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Copyright © 2015 Van de Bugger | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # perl-Dist-Zilla-PluginBundle-Author-VDB is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 10 | # it under the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 11 | # Foundation, either version 3 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | # perl-Dist-Zilla-PluginBundle-Author-VDB is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||
| 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||||||||||||||||||||||||
| 15 | # PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||
| 18 | # perl-Dist-Zilla-PluginBundle-Author-VDB. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||
| 20 | # ---------------------------------------------------------------------- copyright and license --- | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | package Dist::Zilla::Role::Author::VDB::ProgramRunner; | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 7 | ▶ | use version 0.77; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # ABSTRACT: TODO | ||||||||||||||||||||||||||||
| 29 | 7 | our $VERSION = 'v0.11.3.1'; # TRIAL VERSION | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 7 | with 'Dist::Zilla::Role::ErrorLogger'; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 7 | ▶ | use IPC::Run3 qw{}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 7 | ▶ | use String::ShellQuote; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | #pod =method run_program | ||||||||||||||||||||||||||||
| 39 | #pod | ||||||||||||||||||||||||||||
| 40 | #pod @stdout = @{ $self->run_program( $program, @arguments ) }; | ||||||||||||||||||||||||||||
| 41 | #pod | ||||||||||||||||||||||||||||
| 42 | #pod =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub run_program { | ||||||||||||||||||||||||||
|
Subroutine
run_program: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | my ( $self, @cmd ) = @_; | |||||||||||||||||||||||||||
| 46 | 0 | my ( @stdout, @stderr ); | |||||||||||||||||||||||||||
| 47 | 0 | my $program = shell_quote( $cmd[ 0 ] ); | |||||||||||||||||||||||||||
| 48 | 0 | IPC::Run3::run3( \@cmd, \undef, \@stdout, \@stderr, { return_if_system_error => 1 } ); | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( $? < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | my $err = $!; | |||||||||||||||||||||||||||
| 51 | 0 | $self->abort( [ "Can't run program %s: %s", $program, $err ] ); | |||||||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||||||||
| 53 | 0 | my $signal = $? & 0xFE; | |||||||||||||||||||||||||||
| 54 | 0 | my $status = $? >> 8; | |||||||||||||||||||||||||||
| 55 | 0 | chomp( @stdout ); | |||||||||||||||||||||||||||
| 56 | 0 | chomp( @stderr ); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $method = $signal || $status ? 'log_error' : 'log_debug'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$signal or $status
MC/DC0%0/2
$signal or $status
$signal
$status
Truth table0%0/3
A or B
A= $signalB= $status
| |||||||||||||||||||||||||||||
| 58 | 0 | $self->$method( [ "\$ %s", shell_quote( @cmd ) ] ); | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->$method( @stdout ? 'stdout:' : 'stdout is empty' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | $self->$method( " $_" ) for @stdout; | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self->$method( @stderr ? 'stderr:' : 'stderr is empty' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | $self->$method( " $_" ) for @stderr; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ( $signal ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $self->abort( [ "Program %s died with signal %s", $program, $signal ] ); | |||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $status ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | $self->abort( [ "Program %s exited with status %s", $program, $status ] ); | |||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||
| 69 | 0 | return \@stdout; | |||||||||||||||||||||||||||
| 70 | }; | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 7 | 1; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # -------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | #pod =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 79 | #pod | ||||||||||||||||||||||||||||
| 80 | #pod Copyright (C) 2015 Van de Bugger | ||||||||||||||||||||||||||||
| 81 | #pod | ||||||||||||||||||||||||||||
| 82 | #pod License GPLv3+: The GNU General Public License version 3 or later | ||||||||||||||||||||||||||||
| 83 | #pod <http://www.gnu.org/licenses/gpl-3.0.txt>. | ||||||||||||||||||||||||||||
| 84 | #pod | ||||||||||||||||||||||||||||
| 85 | #pod This is free software: you are free to change and redistribute it. There is | ||||||||||||||||||||||||||||
| 86 | #pod NO WARRANTY, to the extent permitted by law. | ||||||||||||||||||||||||||||
| 87 | #pod | ||||||||||||||||||||||||||||
| 88 | #pod | ||||||||||||||||||||||||||||
| 89 | #pod =cut | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # end of file # | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||