line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Plugins; ## no critic (Moose::RequireMakeImmutable) |
2
|
|
|
|
|
|
|
$Mason::t::Plugins::VERSION = '2.23'; |
3
|
1
|
|
|
1
|
|
798
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
29500
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
569
|
use Capture::Tiny qw(capture_merged); |
|
1
|
|
|
|
|
3411
|
|
|
1
|
|
|
|
|
62
|
|
5
|
1
|
|
|
1
|
|
6
|
use Mason::Util qw(dump_one_line); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
195
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub test_notify_plugin : Tests { |
8
|
1
|
|
|
1
|
0
|
858
|
my $self = shift; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
8
|
$self->setup_interp( |
11
|
|
|
|
|
|
|
plugins => ['+Mason::Test::Plugins::Notify'], |
12
|
|
|
|
|
|
|
no_source_line_numbers => 1, |
13
|
|
|
|
|
|
|
); |
14
|
1
|
|
|
|
|
27
|
$self->add_comp( path => '/test_plugin_support.mi', src => 'hi' ); |
15
|
|
|
|
|
|
|
my $output = capture_merged { |
16
|
1
|
|
|
1
|
|
1061
|
$self->test_comp( |
17
|
|
|
|
|
|
|
path => '/test_plugin.mc', |
18
|
|
|
|
|
|
|
src => '<& test_plugin_support.mi &>', |
19
|
|
|
|
|
|
|
expect => 'hi' |
20
|
|
|
|
|
|
|
); |
21
|
1
|
|
|
|
|
31
|
}; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
4
|
|
754
|
my $like = sub { my $regex = shift; like( $output, $regex, $regex ) }; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
12
|
|
24
|
1
|
|
|
|
|
7
|
$like->(qr/starting interp run/); |
25
|
1
|
|
|
|
|
400
|
$like->(qr/starting request run - \/test_plugin/); |
26
|
1
|
|
|
|
|
372
|
$like->(qr/starting request comp - test_plugin_support.mi/); |
27
|
1
|
|
|
|
|
371
|
$like->(qr/starting compilation parse - \/test_plugin.mc/); |
28
|
1
|
|
|
1
|
|
6
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Call Mason::Test::RootClass->new, then make base classes like |
31
|
|
|
|
|
|
|
# Mason::Test::RootClass::Interp are used automatically |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
sub test_notify_root_class : Tests { |
34
|
1
|
|
|
1
|
0
|
600
|
my $self = shift; |
35
|
1
|
|
|
|
|
2
|
my $mrc = 'Mason::Test::RootClass'; |
36
|
1
|
|
|
|
|
8
|
$self->setup_interp( mason_root_class => $mrc ); |
37
|
1
|
|
|
|
|
32
|
is( $self->interp->mason_root_class, $mrc, "mason_root_class" ); |
38
|
1
|
|
|
|
|
611
|
is( $self->interp->base_compilation_class, "${mrc}::Compilation", "base_compilation_class" ); |
39
|
1
|
|
|
|
|
595
|
is( $self->interp->base_component_class, "${mrc}::Component", "base_component_class" ); |
40
|
1
|
|
|
|
|
581
|
is( $self->interp->base_request_class, "${mrc}::Request", "base_request_class" ); |
41
|
1
|
|
|
|
|
344
|
is( $self->interp->base_result_class, "Mason::Result", "base_result_class" ); |
42
|
1
|
|
|
|
|
386
|
isa_ok( $self->interp, "${mrc}::Interp", "base_interp_class" ); |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
402
|
$self->add_comp( path => '/test_plugin_support.mi', src => 'hi' ); |
45
|
|
|
|
|
|
|
my $output = capture_merged { |
46
|
1
|
|
|
1
|
|
902
|
$self->test_comp( |
47
|
|
|
|
|
|
|
path => '/test_plugin.mc', |
48
|
|
|
|
|
|
|
src => '<& test_plugin_support.mi &>', |
49
|
|
|
|
|
|
|
expect => 'hi' |
50
|
|
|
|
|
|
|
); |
51
|
1
|
|
|
|
|
35
|
}; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
4
|
|
57347
|
my $like = sub { my $regex = shift; like( $output, $regex, $regex ) }; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
16
|
|
54
|
1
|
|
|
|
|
19
|
$like->(qr/starting interp run/); |
55
|
1
|
|
|
|
|
966
|
$like->(qr/starting request run - \/test_plugin/); |
56
|
1
|
|
|
|
|
434
|
$like->(qr/starting request comp - test_plugin_support.mi/); |
57
|
1
|
|
|
|
|
377
|
$like->(qr/starting compilation parse - \/test_plugin.mc/); |
58
|
1
|
|
|
1
|
|
469
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub test_strict_plugin : Tests { |
61
|
1
|
|
|
1
|
0
|
279
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
9
|
$self->setup_interp( |
64
|
|
|
|
|
|
|
base_component_moose_class => 'Mason::Test::Overrides::Component::StrictMoose', ); |
65
|
1
|
|
|
|
|
157
|
$self->add_comp( path => '/test_strict_plugin.mc', src => 'hi' ); |
66
|
1
|
|
|
1
|
|
11
|
lives_ok { $self->interp->run('/test_strict_plugin') }; |
|
1
|
|
|
|
|
39
|
|
67
|
1
|
|
|
1
|
|
684
|
throws_ok { $self->interp->run( '/test_strict_plugin', foo => 5 ) } qr/Found unknown attribute/; |
|
1
|
|
|
|
|
57
|
|
68
|
1
|
|
|
1
|
|
286
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
package Mason::Test::Plugins::A; |
72
|
|
|
|
|
|
|
$Mason::Test::Plugins::A::VERSION = '2.23'; |
73
|
1
|
|
|
1
|
|
198
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
74
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
package Mason::Plugin::B; |
78
|
|
|
|
|
|
|
$Mason::Plugin::B::VERSION = '2.23'; |
79
|
1
|
|
|
1
|
|
5079
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
80
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
package Mason::Plugin::C; |
84
|
|
|
|
|
|
|
$Mason::Plugin::C::VERSION = '2.23'; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
4722
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
87
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
package Mason::Plugin::D; |
91
|
|
|
|
|
|
|
$Mason::Plugin::D::VERSION = '2.23'; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
1
|
|
4655
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
94
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
package Mason::Plugin::E; |
98
|
|
|
|
|
|
|
$Mason::Plugin::E::VERSION = '2.23'; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
1
|
|
4633
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
101
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
{ |
104
|
|
|
|
|
|
|
package Mason::PluginBundle::F; |
105
|
|
|
|
|
|
|
$Mason::PluginBundle::F::VERSION = '2.23'; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
1
|
|
4787
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
108
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
109
|
6
|
|
|
6
|
0
|
28
|
sub requires_plugins { return qw(C D) } |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
package Mason::Test::PluginBundle::G; |
113
|
|
|
|
|
|
|
$Mason::Test::PluginBundle::G::VERSION = '2.23'; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
1
|
|
4557
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
116
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
117
|
4
|
|
|
4
|
0
|
18
|
sub requires_plugins { return qw(C E) } |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
package Mason::Plugin::H; |
121
|
|
|
|
|
|
|
$Mason::Plugin::H::VERSION = '2.23'; |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
1
|
|
4605
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
124
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
125
|
1
|
|
|
1
|
0
|
4
|
sub requires_plugins { return qw(@F) } |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
{ |
128
|
|
|
|
|
|
|
package Mason::PluginBundle::I; |
129
|
|
|
|
|
|
|
$Mason::PluginBundle::I::VERSION = '2.23'; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
1
|
|
4625
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
132
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub requires_plugins { |
135
|
4
|
|
|
4
|
0
|
21
|
return ( '+Mason::Test::Plugins::A', 'B', '@F', '+Mason::Test::PluginBundle::G', ); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
package Mason::PluginBundle::J; |
141
|
|
|
|
|
|
|
$Mason::PluginBundle::J::VERSION = '2.23'; |
142
|
|
|
|
|
|
|
|
143
|
1
|
|
|
1
|
|
4761
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
144
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub requires_plugins { |
147
|
1
|
|
|
1
|
0
|
6
|
return ('@I'); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub test_plugin_specs : Tests { |
152
|
1
|
|
|
1
|
0
|
883
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
1
|
|
|
|
|
10
|
require Mason::PluginBundle::Default; |
155
|
1
|
50
|
|
|
|
10
|
my @default_plugins = Mason::PluginBundle::Default->requires_plugins |
156
|
|
|
|
|
|
|
or die "no default plugins"; |
157
|
|
|
|
|
|
|
my $test = sub { |
158
|
9
|
|
|
9
|
|
20
|
my ( $plugin_list, $expected_plugins ) = @_; |
159
|
9
|
|
|
|
|
63
|
my $interp = Mason->new( comp_root => $self->comp_root, plugins => $plugin_list ); |
160
|
28
|
100
|
|
|
|
97
|
my $got_plugins = |
161
|
7
|
|
|
|
|
16
|
[ map { /Mason::Plugin::/ ? substr( $_, 15 ) : $_ } @{ $interp->plugins } ]; |
|
7
|
|
|
|
|
171
|
|
162
|
7
|
|
|
|
|
48
|
cmp_deeply( |
163
|
|
|
|
|
|
|
$got_plugins, |
164
|
|
|
|
|
|
|
[ @$expected_plugins, @default_plugins ], |
165
|
|
|
|
|
|
|
dump_one_line($plugin_list) |
166
|
|
|
|
|
|
|
); |
167
|
1
|
|
|
|
|
8
|
}; |
168
|
1
|
|
|
|
|
3
|
$test->( [], [] ); |
169
|
1
|
|
|
|
|
20
|
$test->( ['E'], ['E'] ); |
170
|
1
|
|
|
|
|
14
|
$test->( ['H'], [ 'H', 'C', 'D' ] ); |
171
|
1
|
|
|
|
|
11
|
$test->( ['@F'], [ 'C', 'D' ] ); |
172
|
1
|
|
|
|
|
12
|
$test->( ['@I'], [ 'Mason::Test::Plugins::A', 'B', 'C', 'D', 'E' ] ); |
173
|
1
|
|
|
|
|
18
|
$test->( [ '-C', '@I', '-+Mason::Test::Plugins::A' ], [ 'B', 'D', 'E' ] ); |
174
|
1
|
|
|
|
|
12
|
$test->( [ '-@I', '@J' ], [] ); |
175
|
1
|
|
|
1
|
|
18
|
throws_ok { $test->( ['@X'] ) } qr/could not load 'Mason::PluginBundle::X'/; |
|
1
|
|
|
|
|
70
|
|
176
|
1
|
|
|
1
|
|
482
|
throws_ok { $test->( ['Y'] ) } qr/could not load 'Mason::Plugin::Y'/; |
|
1
|
|
|
|
|
39
|
|
177
|
1
|
|
|
1
|
|
5085
|
} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
{ |
180
|
|
|
|
|
|
|
package Mason::Test::Plugins::Upper; |
181
|
|
|
|
|
|
|
$Mason::Test::Plugins::Upper::VERSION = '2.23'; |
182
|
|
|
|
|
|
|
|
183
|
1
|
|
|
1
|
|
288
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
184
|
|
|
|
|
|
|
with 'Mason::Plugin' |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
{ |
187
|
|
|
|
|
|
|
package Mason::Test::Plugins::Upper::Request; |
188
|
|
|
|
|
|
|
$Mason::Test::Plugins::Upper::Request::VERSION = '2.23'; |
189
|
|
|
|
|
|
|
|
190
|
1
|
|
|
1
|
|
5284
|
use Mason::PluginRole; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
191
|
|
|
|
|
|
|
after 'process_output' => sub { |
192
|
|
|
|
|
|
|
my ( $self, $bufref ) = @_; |
193
|
|
|
|
|
|
|
$$bufref = uc($$bufref); |
194
|
|
|
|
|
|
|
}; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub test_process_output_plugin : Tests { |
198
|
1
|
|
|
1
|
0
|
711
|
my $self = shift; |
199
|
|
|
|
|
|
|
|
200
|
1
|
|
|
|
|
9
|
$self->setup_interp( plugins => ['+Mason::Test::Plugins::Upper'] ); |
201
|
1
|
|
|
|
|
34
|
$self->test_comp( src => 'Hello', expect => 'HELLO' ); |
202
|
1
|
|
|
1
|
|
4301
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |