line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Plugins; ## no critic (Moose::RequireMakeImmutable) |
2
|
|
|
|
|
|
|
$Mason::t::Plugins::VERSION = '2.24'; |
3
|
1
|
|
|
1
|
|
788
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
32379
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
637
|
use Capture::Tiny qw(capture_merged); |
|
1
|
|
|
|
|
3206
|
|
|
1
|
|
|
|
|
59
|
|
5
|
1
|
|
|
1
|
|
5
|
use Mason::Util qw(dump_one_line); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
190
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub test_notify_plugin : Tests { |
8
|
1
|
|
|
1
|
0
|
772
|
my $self = shift; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
7
|
$self->setup_interp( |
11
|
|
|
|
|
|
|
plugins => ['+Mason::Test::Plugins::Notify'], |
12
|
|
|
|
|
|
|
no_source_line_numbers => 1, |
13
|
|
|
|
|
|
|
); |
14
|
1
|
|
|
|
|
30
|
$self->add_comp( path => '/test_plugin_support.mi', src => 'hi' ); |
15
|
|
|
|
|
|
|
my $output = capture_merged { |
16
|
1
|
|
|
1
|
|
1041
|
$self->test_comp( |
17
|
|
|
|
|
|
|
path => '/test_plugin.mc', |
18
|
|
|
|
|
|
|
src => '<& test_plugin_support.mi &>', |
19
|
|
|
|
|
|
|
expect => 'hi' |
20
|
|
|
|
|
|
|
); |
21
|
1
|
|
|
|
|
32
|
}; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
4
|
|
747
|
my $like = sub { my $regex = shift; like( $output, $regex, $regex ) }; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
12
|
|
24
|
1
|
|
|
|
|
7
|
$like->(qr/starting interp run/); |
25
|
1
|
|
|
|
|
291
|
$like->(qr/starting request run - \/test_plugin/); |
26
|
1
|
|
|
|
|
245
|
$like->(qr/starting request comp - test_plugin_support.mi/); |
27
|
1
|
|
|
|
|
241
|
$like->(qr/starting compilation parse - \/test_plugin.mc/); |
28
|
1
|
|
|
1
|
|
20
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
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
|
466
|
my $self = shift; |
35
|
1
|
|
|
|
|
3
|
my $mrc = 'Mason::Test::RootClass'; |
36
|
1
|
|
|
|
|
8
|
$self->setup_interp( mason_root_class => $mrc ); |
37
|
1
|
|
|
|
|
29
|
is( $self->interp->mason_root_class, $mrc, "mason_root_class" ); |
38
|
1
|
|
|
|
|
326
|
is( $self->interp->base_compilation_class, "${mrc}::Compilation", "base_compilation_class" ); |
39
|
1
|
|
|
|
|
321
|
is( $self->interp->base_component_class, "${mrc}::Component", "base_component_class" ); |
40
|
1
|
|
|
|
|
534
|
is( $self->interp->base_request_class, "${mrc}::Request", "base_request_class" ); |
41
|
1
|
|
|
|
|
370
|
is( $self->interp->base_result_class, "Mason::Result", "base_result_class" ); |
42
|
1
|
|
|
|
|
351
|
isa_ok( $self->interp, "${mrc}::Interp", "base_interp_class" ); |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
408
|
$self->add_comp( path => '/test_plugin_support.mi', src => 'hi' ); |
45
|
|
|
|
|
|
|
my $output = capture_merged { |
46
|
1
|
|
|
1
|
|
799
|
$self->test_comp( |
47
|
|
|
|
|
|
|
path => '/test_plugin.mc', |
48
|
|
|
|
|
|
|
src => '<& test_plugin_support.mi &>', |
49
|
|
|
|
|
|
|
expect => 'hi' |
50
|
|
|
|
|
|
|
); |
51
|
1
|
|
|
|
|
32
|
}; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
4
|
|
834
|
my $like = sub { my $regex = shift; like( $output, $regex, $regex ) }; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
11
|
|
54
|
1
|
|
|
|
|
7
|
$like->(qr/starting interp run/); |
55
|
1
|
|
|
|
|
386
|
$like->(qr/starting request run - \/test_plugin/); |
56
|
1
|
|
|
|
|
356
|
$like->(qr/starting request comp - test_plugin_support.mi/); |
57
|
1
|
|
|
|
|
354
|
$like->(qr/starting compilation parse - \/test_plugin.mc/); |
58
|
1
|
|
|
1
|
|
546
|
} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub test_strict_plugin : Tests { |
61
|
1
|
|
|
1
|
0
|
228
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
7
|
$self->setup_interp( |
64
|
|
|
|
|
|
|
base_component_moose_class => 'Mason::Test::Overrides::Component::StrictMoose', ); |
65
|
1
|
|
|
|
|
24
|
$self->add_comp( path => '/test_strict_plugin.mc', src => 'hi' ); |
66
|
1
|
|
|
1
|
|
8
|
lives_ok { $self->interp->run('/test_strict_plugin') }; |
|
1
|
|
|
|
|
29
|
|
67
|
1
|
|
|
1
|
|
558
|
throws_ok { $self->interp->run( '/test_strict_plugin', foo => 5 ) } qr/Found unknown attribute/; |
|
1
|
|
|
|
|
47
|
|
68
|
1
|
|
|
1
|
|
255
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
package Mason::Test::Plugins::A; |
72
|
|
|
|
|
|
|
$Mason::Test::Plugins::A::VERSION = '2.24'; |
73
|
1
|
|
|
1
|
|
199
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
74
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
package Mason::Plugin::B; |
78
|
|
|
|
|
|
|
$Mason::Plugin::B::VERSION = '2.24'; |
79
|
1
|
|
|
1
|
|
4968
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
80
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
package Mason::Plugin::C; |
84
|
|
|
|
|
|
|
$Mason::Plugin::C::VERSION = '2.24'; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
4563
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
87
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
package Mason::Plugin::D; |
91
|
|
|
|
|
|
|
$Mason::Plugin::D::VERSION = '2.24'; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
1
|
|
4571
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
94
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
package Mason::Plugin::E; |
98
|
|
|
|
|
|
|
$Mason::Plugin::E::VERSION = '2.24'; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
1
|
|
4657
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
101
|
|
|
|
|
|
|
with 'Mason::Plugin'; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
{ |
104
|
|
|
|
|
|
|
package Mason::PluginBundle::F; |
105
|
|
|
|
|
|
|
$Mason::PluginBundle::F::VERSION = '2.24'; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
1
|
|
4751
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
108
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
109
|
6
|
|
|
6
|
0
|
30
|
sub requires_plugins { return qw(C D) } |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
package Mason::Test::PluginBundle::G; |
113
|
|
|
|
|
|
|
$Mason::Test::PluginBundle::G::VERSION = '2.24'; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
1
|
|
4581
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
116
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
117
|
4
|
|
|
4
|
0
|
16
|
sub requires_plugins { return qw(C E) } |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
package Mason::Plugin::H; |
121
|
|
|
|
|
|
|
$Mason::Plugin::H::VERSION = '2.24'; |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
1
|
|
4364
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
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.24'; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
1
|
|
4556
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
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.24'; |
142
|
|
|
|
|
|
|
|
143
|
1
|
|
|
1
|
|
4429
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
144
|
|
|
|
|
|
|
with 'Mason::PluginBundle'; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub requires_plugins { |
147
|
1
|
|
|
1
|
0
|
7
|
return ('@I'); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub test_plugin_specs : Tests { |
152
|
1
|
|
|
1
|
0
|
593
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
1
|
|
|
|
|
8
|
require Mason::PluginBundle::Default; |
155
|
1
|
50
|
|
|
|
8
|
my @default_plugins = Mason::PluginBundle::Default->requires_plugins |
156
|
|
|
|
|
|
|
or die "no default plugins"; |
157
|
|
|
|
|
|
|
my $test = sub { |
158
|
9
|
|
|
9
|
|
16
|
my ( $plugin_list, $expected_plugins ) = @_; |
159
|
9
|
|
|
|
|
57
|
my $interp = Mason->new( comp_root => $self->comp_root, plugins => $plugin_list ); |
160
|
28
|
100
|
|
|
|
76
|
my $got_plugins = |
161
|
7
|
|
|
|
|
13
|
[ map { /Mason::Plugin::/ ? substr( $_, 15 ) : $_ } @{ $interp->plugins } ]; |
|
7
|
|
|
|
|
158
|
|
162
|
7
|
|
|
|
|
45
|
cmp_deeply( |
163
|
|
|
|
|
|
|
$got_plugins, |
164
|
|
|
|
|
|
|
[ @$expected_plugins, @default_plugins ], |
165
|
|
|
|
|
|
|
dump_one_line($plugin_list) |
166
|
|
|
|
|
|
|
); |
167
|
1
|
|
|
|
|
6
|
}; |
168
|
1
|
|
|
|
|
2
|
$test->( [], [] ); |
169
|
1
|
|
|
|
|
17
|
$test->( ['E'], ['E'] ); |
170
|
1
|
|
|
|
|
14
|
$test->( ['H'], [ 'H', 'C', 'D' ] ); |
171
|
1
|
|
|
|
|
11
|
$test->( ['@F'], [ 'C', 'D' ] ); |
172
|
1
|
|
|
|
|
18
|
$test->( ['@I'], [ 'Mason::Test::Plugins::A', 'B', 'C', 'D', 'E' ] ); |
173
|
1
|
|
|
|
|
12
|
$test->( [ '-C', '@I', '-+Mason::Test::Plugins::A' ], [ 'B', 'D', 'E' ] ); |
174
|
1
|
|
|
|
|
12
|
$test->( [ '-@I', '@J' ], [] ); |
175
|
1
|
|
|
1
|
|
16
|
throws_ok { $test->( ['@X'] ) } qr/could not load 'Mason::PluginBundle::X'/; |
|
1
|
|
|
|
|
66
|
|
176
|
1
|
|
|
1
|
|
434
|
throws_ok { $test->( ['Y'] ) } qr/could not load 'Mason::Plugin::Y'/; |
|
1
|
|
|
|
|
32
|
|
177
|
1
|
|
|
1
|
|
5056
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
{ |
180
|
|
|
|
|
|
|
package Mason::Test::Plugins::Upper; |
181
|
|
|
|
|
|
|
$Mason::Test::Plugins::Upper::VERSION = '2.24'; |
182
|
|
|
|
|
|
|
|
183
|
1
|
|
|
1
|
|
276
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
184
|
|
|
|
|
|
|
with 'Mason::Plugin' |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
{ |
187
|
|
|
|
|
|
|
package Mason::Test::Plugins::Upper::Request; |
188
|
|
|
|
|
|
|
$Mason::Test::Plugins::Upper::Request::VERSION = '2.24'; |
189
|
|
|
|
|
|
|
|
190
|
1
|
|
|
1
|
|
5455
|
use Mason::PluginRole; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
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
|
575
|
my $self = shift; |
199
|
|
|
|
|
|
|
|
200
|
1
|
|
|
|
|
8
|
$self->setup_interp( plugins => ['+Mason::Test::Plugins::Upper'] ); |
201
|
1
|
|
|
|
|
31
|
$self->test_comp( src => 'Hello', expect => 'HELLO' ); |
202
|
1
|
|
|
1
|
|
4430
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |