line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Git::Workflow::Command; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2014-09-23 06:44:54 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
19
|
|
|
19
|
|
32014
|
use strict; |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
543
|
|
10
|
19
|
|
|
19
|
|
99
|
use warnings; |
|
19
|
|
|
|
|
41
|
|
|
19
|
|
|
|
|
492
|
|
11
|
19
|
|
|
19
|
|
89
|
use version; |
|
19
|
|
|
|
|
32
|
|
|
19
|
|
|
|
|
122
|
|
12
|
19
|
|
|
19
|
|
1248
|
use Carp; |
|
19
|
|
|
|
|
44
|
|
|
19
|
|
|
|
|
1207
|
|
13
|
19
|
|
|
19
|
|
137
|
use English qw/ -no_match_vars /; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
128
|
|
14
|
19
|
|
|
19
|
|
6600
|
use base qw/Exporter/; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
1319
|
|
15
|
19
|
|
|
19
|
|
112
|
use Test::More; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
273
|
|
16
|
19
|
|
|
19
|
|
15452
|
use Capture::Tiny qw/capture/; |
|
19
|
|
|
|
|
396681
|
|
|
19
|
|
|
|
|
1383
|
|
17
|
19
|
|
|
19
|
|
191
|
use App::Git::Workflow; |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
730
|
|
18
|
19
|
|
|
19
|
|
8202
|
use Mock::App::Git::Workflow::Repository; |
|
19
|
|
|
|
|
72
|
|
|
19
|
|
|
|
|
2948
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = version->new(1.1.16); |
21
|
|
|
|
|
|
|
our @EXPORT = qw/command_ok/; |
22
|
|
|
|
|
|
|
our @EXPORT_OK = qw/command_ok/; |
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = (); |
24
|
|
|
|
|
|
|
our $workflow = 'App::Git::Workflow'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $git = Mock::App::Git::Workflow::Repository->git; |
27
|
|
|
|
|
|
|
%App::Git::Workflow::Command::p2u_extra = ( -exitval => 'NOEXIT', ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub command_ok ($$) { ## no critic |
30
|
100
|
|
|
100
|
1
|
207951
|
my ($module, $data) = @_; |
31
|
|
|
|
|
|
|
subtest $data->{name} => sub { |
32
|
19
|
|
|
19
|
|
213
|
no strict qw/refs/; ## no critic |
|
19
|
|
|
|
|
88
|
|
|
19
|
|
|
|
|
16396
|
|
33
|
|
|
|
|
|
|
|
34
|
100
|
100
|
100
|
100
|
|
118177
|
if ($data->{skip} && $data->{skip}->()) { |
35
|
1
|
|
|
|
|
10
|
plan skip_all => "Skipping $data->{name}"; |
36
|
0
|
|
|
|
|
0
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
99
|
|
|
|
|
8777
|
local $TODO; |
39
|
99
|
50
|
|
|
|
279
|
if ($data->{todo}) { |
40
|
0
|
|
|
|
|
0
|
$TODO = $data->{todo}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# initialise |
44
|
99
|
|
|
|
|
516
|
$git->mock_reset(); |
45
|
99
|
|
|
|
|
175
|
$git->mock_add(@{ $data->{mock} }); |
|
99
|
|
|
|
|
411
|
|
46
|
|
|
|
|
|
|
|
47
|
99
|
|
|
|
|
312
|
$git->{ran} = []; |
48
|
99
|
|
|
|
|
176
|
%{"${module}::option"} = (); |
|
99
|
|
|
|
|
709
|
|
49
|
99
|
|
|
|
|
668
|
${"${module}::workflow"} = $workflow->new(git => $git); |
|
99
|
|
|
|
|
921
|
|
50
|
99
|
100
|
|
|
|
326
|
if ($data->{workflow}) { |
51
|
6
|
|
|
|
|
11
|
${"${module}::workflow"}->{$_} = $data->{workflow}{$_} for keys %{ $data->{workflow} }; |
|
6
|
|
|
|
|
27
|
|
|
6
|
|
|
|
|
27
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
99
|
|
|
|
|
166
|
local @ARGV = @{ $data->{ARGV} }; |
|
99
|
|
|
|
|
359
|
|
55
|
99
|
|
|
|
|
5050
|
local %ENV = %ENV; |
56
|
99
|
100
|
|
|
|
432
|
if ($data->{ENV}) { |
57
|
2
|
|
|
|
|
5
|
$ENV{$_} = $data->{ENV}{$_} for keys %{ $data->{ENV} }; |
|
2
|
|
|
|
|
15
|
|
58
|
|
|
|
|
|
|
} |
59
|
99
|
|
|
|
|
169
|
my $stdin; |
60
|
99
|
|
100
|
|
|
577
|
$data->{STD}{IN} ||= ''; |
61
|
99
|
|
|
17
|
|
2037
|
open $stdin, '<', \$data->{STD}{IN}; |
|
17
|
|
|
|
|
141
|
|
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
162
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# run the code |
64
|
99
|
|
|
|
|
13098
|
my $error; |
65
|
99
|
|
|
|
|
3177
|
my ($stdout, $stderr) = capture { local *STDIN = $stdin; eval { $module->run() }; $error = $@; }; |
|
99
|
|
|
|
|
113446
|
|
|
99
|
|
|
|
|
213
|
|
|
99
|
|
|
|
|
840
|
|
|
99
|
|
|
|
|
676
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
## Tests |
68
|
99
|
100
|
|
|
|
84169
|
if ($error) { |
69
|
|
|
|
|
|
|
#die $error, $stderr if !$data->{error}; |
70
|
|
|
|
|
|
|
is $error, $data->{error}, "Error matches" |
71
|
6
|
50
|
0
|
|
|
61
|
or ( ref $error && diag explain $error, $data->{error} ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# STDOUT |
75
|
99
|
100
|
|
|
|
4280
|
if ( !ref $data->{STD}{OUT} ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
76
|
|
|
|
|
|
|
is $stdout, $data->{STD}{OUT}, "STDOUT $data->{name} run" |
77
|
67
|
50
|
|
|
|
531
|
or diag explain $stdout, $data->{STD}{OUT}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
elsif ( ref $data->{STD}{OUT} eq 'Regexp' ) { |
80
|
|
|
|
|
|
|
like $stdout, $data->{STD}{OUT}, "STDOUT $data->{name} run" |
81
|
31
|
50
|
|
|
|
249
|
or diag explain $stdout, $data->{STD}{OUT}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
elsif ( ref $data->{STD}{OUT} eq 'HASH' ) { |
84
|
1
|
50
|
|
|
|
5
|
my $actual = $data->{STD}{OUT_PRE} ? eval { $data->{STD}{OUT_PRE}->($stdout) } : $stdout; |
|
1
|
|
|
|
|
7
|
|
85
|
|
|
|
|
|
|
#diag explain [$stdout, $data, $@] if $@; |
86
|
|
|
|
|
|
|
is_deeply $actual, $data->{STD}{OUT}, "STDOUT $data->{name} run" |
87
|
1
|
50
|
|
|
|
23
|
or diag explain $actual, $data->{STD}{OUT}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# STDERR |
91
|
99
|
100
|
|
|
|
59542
|
if ( !ref $data->{STD}{ERR} ) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
92
|
|
|
|
|
|
|
is $stderr, $data->{STD}{ERR}, "STDERR $data->{name} run" |
93
|
70
|
50
|
|
|
|
409
|
or diag explain $stderr, $data->{STD}{ERR}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( ref $data->{STD}{ERR} eq 'Regexp' ) { |
96
|
|
|
|
|
|
|
like $stderr, $data->{STD}{ERR}, "STDERR $data->{name} run" |
97
|
29
|
50
|
|
|
|
155
|
or diag explain $stderr, $data->{STD}{ERR}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
elsif ( ref $data->{STD}{ERR} eq 'HASH' ) { |
100
|
0
|
0
|
|
|
|
0
|
my $actual = $data->{STD}{ERR_PRE} ? $data->{STD}{ERR_PRE}->($stdout) : $stdout; |
101
|
|
|
|
|
|
|
is_deeply $actual, $data->{STD}{ERR}, "STDERR $data->{name} run" |
102
|
0
|
0
|
|
|
|
0
|
or diag explain $actual, $data->{STD}{ERR}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
99
|
|
|
|
|
1046
|
is_deeply \%{"${module}::option"}, $data->{option}, 'Options set correctly' |
106
|
99
|
50
|
|
|
|
45717
|
or diag explain \%{"${module}::option"}, $data->{option}; |
|
0
|
|
|
|
|
0
|
|
107
|
99
|
|
|
|
|
503
|
ok !@{ $git->{data} }, "All data setup is used" |
108
|
99
|
50
|
|
|
|
70958
|
or diag explain $git->{data}, [ map {keys %$_} @{ $data->{mock} } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
109
|
100
|
|
|
|
|
1069
|
}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 NAME |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Test::Git::Workflow::Command - Test Git::Workflow::Command::* files |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 VERSION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This documentation refers to Test::Git::Workflow::Command version 1.1.16 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
use Test::Git::Workflow::Command; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
command_ok('Test::Git::Workflow::Command::SomeCommand', {...}); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 DESCRIPTION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Helper module to test L<Git::Worflow::Commands>s |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 C<command_ok ( $module, $data )> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Tests C<$module> with the supplied <C$data> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
C<$data> keys |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item ARGV |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The commands command line input |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item mock |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The mock data to supply to the L<Mock::App::Git::Workflow::Repository> object |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item STD |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item IN |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
STDIN |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item OUT |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
STDOUT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item ERR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
STDERR |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item option |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
What the C<%option>s hash should contain at the end of everything |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item name |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Name of the test |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
There are no known bugs in this module. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Patches are welcome. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
203
|
|
|
|
|
|
|
All rights reserved. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
206
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
207
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
208
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
209
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |