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