Login
Add can_be_disabled() to the trusted method list
[gknop/Perl-Critic.git] / t / 99_pod_coverage.t
CommitLineData
faa35de4
JRT
1#!perl
2
6036a254 3##############################################################################
27c1472f
JRT
4# $URL$
5# $Date$
6# $Author$
7# $Revision$
6036a254 8##############################################################################
27c1472f 9
df6dee2b 10use 5.006001;
59b05e08
JRT
11use strict;
12use warnings;
b185fa17 13
1ced16e9
ES
14use English qw< -no_match_vars >;
15
59b05e08
JRT
16use Test::More;
17
b185fa17
ES
18#-----------------------------------------------------------------------------
19
173667ce 20our $VERSION = '1.093_01';
b185fa17
ES
21
22#-----------------------------------------------------------------------------
23
32c50ab8 24eval 'use Test::Pod::Coverage 1.04'; ## no critic
1ced16e9
ES
25plan skip_all => 'Test::Pod::Coverage 1.00 requried to test POD'
26 if $EVAL_ERROR;
acd594cd
JRT
27
28{
29 # HACK: Perl::Critic::Violation uses Pod::Parser to extract the
30 # DIAGNOSTIC section of the POD in each Policy module. This
31 # happens when the Policy first C<uses> the Violation module.
32 # Meanwhile, Pod::Coverage also uses Pod::Parser to extract the
33 # POD and compare it with the subroutines that are in the symbol
34 # table for that module. For reasons I cannot yet explain, using
35 # Pod::Parser twice this way causes the symbol table to get very
36 # wacky and this test script dies with "Can't call method 'OPEN'
37 # on IO::String at line 1239 of Pod/Parser.pm".
38
39 # For now, my workaround is to temporarily redefine the import()
40 # method in the Violation module so that it doesn't do any Pod
41 # parsing. I'll look for a better solution (or file a bug report)
42 # when / if I have better understanding of the problem.
43
5c1b319c 44 no warnings qw<redefine once>; ## no critic (ProhibitNoWarnings)
acd594cd
JRT
45 require Perl::Critic::Violation;
46 *Perl::Critic::Violation::import = sub { 1 };
47}
48
faa35de4
JRT
49my @trusted_methods = get_trusted_methods();
50my $method_string = join ' | ', @trusted_methods;
fa2636c4 51my $trusted_rx = qr{ \A (?: $method_string ) \z }xms;
faa35de4
JRT
52all_pod_coverage_ok( {trustme => [$trusted_rx]} );
53
54#-----------------------------------------------------------------------------
55
56sub get_trusted_methods {
57 return qw(
58 new
985e0116 59 initialize_if_enabled
df4662ae 60 can_be_disabled
78afb6d4 61 prepare_to_scan_document
faa35de4
JRT
62 violates
63 applies_to
64 default_themes
6b79d701 65 default_maximum_violations_per_document
faa35de4 66 default_severity
e178fe38 67 supported_parameters
3fff51e5
ES
68 description
69 Fields
48336a64 70 got_sigpipe
faa35de4
JRT
71 );
72}
737d3b65 73
fd5bd7b5 74##############################################################################
737d3b65
CD
75# Local Variables:
76# mode: cperl
77# cperl-indent-level: 4
78# fill-column: 78
79# indent-tabs-mode: nil
80# c-indentation-style: bsd
81# End:
96fed375 82# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :