Skip error/warn frames within CAG - saner callsite error messages this way
[dbsrgits/DBIx-Class.git] / xt / podcoverage.t
CommitLineData
dc4600b2 1use warnings;
2use strict;
3
0fe5201a 4use Test::More;
6298a324 5use List::Util 'first';
dc4600b2 6use lib qw(t/lib);
7use DBICTest;
6298a324 8use namespace::clean;
0fe5201a 9
dc4600b2 10# Don't run tests for installs
39c9c72d 11if ( DBICTest::RunMode->is_plain ) {
dc4600b2 12 plan( skip_all => "Author tests not required for installation" );
13}
0fe5201a 14
a109c954 15require DBIx::Class;
16unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_podcoverage') ) {
17 my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_podcoverage');
6b01a153 18 $ENV{RELEASE_TESTING} || DBICTest::RunMode->is_author
a109c954 19 ? die ("Failed to load release-testing module requirements: $missing")
20 : plan skip_all => "Test needs: $missing"
dc4600b2 21}
7eb4ecc8 22
9b83fccd 23# Since this is about checking documentation, a little documentation
32978f6e 24# of what this is doing might be in order.
9b83fccd 25# The exceptions structure below is a hash keyed by the module
32978f6e 26# name. Any * in a name is treated like a wildcard and will behave
8c96bbc2 27# as expected. Modules are matched by longest string first, so
32978f6e 28# A::B::C will match even if there is A::B*
29
30# The value for each is a hash, which contains one or more
9b83fccd 31# (although currently more than one makes no sense) of the following
32# things:-
33# skip => a true value means this module is not checked
34# ignore => array ref containing list of methods which
35# do not need to be documented.
7eb4ecc8 36my $exceptions = {
37 'DBIx::Class' => {
517ba890 38 ignore => [qw/
39 MODIFY_CODE_ATTRIBUTES
40 component_base_class
41 mk_classdata
42 mk_classaccessor
43 /]
b20edc27 44 },
70c28808 45 'DBIx::Class::Carp' => {
46 ignore => [qw/
47 unimport
48 /]
49 },
0c62fa59 50 'DBIx::Class::Row' => {
517ba890 51 ignore => [qw/
52 MULTICREATE_DEBUG
53 /],
0c62fa59 54 },
1f870d5a 55 'DBIx::Class::Storage::TxnScopeGuard' => {
56 ignore => [qw/
57 IS_BROKEN_PERL
58 /],
59 },
cde96798 60 'DBIx::Class::FilterColumn' => {
61 ignore => [qw/
62 new
63 update
491c8ff9 64 store_column
65 get_column
66 get_columns
cde96798 67 /],
68 },
bc984450 69 'DBIx::Class::ResultSource' => {
70 ignore => [qw/
517ba890 71 compare_relationship_keys
72 pk_depends_on
73 resolve_condition
74 resolve_join
75 resolve_prefetch
50261284 76 STORABLE_freeze
77 STORABLE_thaw
517ba890 78 /],
79 },
0b66414b 80 'DBIx::Class::ResultSet' => {
81 ignore => [qw/
82 STORABLE_freeze
83 STORABLE_thaw
84 /],
85 },
517ba890 86 'DBIx::Class::ResultSourceHandle' => {
87 ignore => [qw/
88 schema
89 source_moniker
bc984450 90 /],
91 },
b20edc27 92 'DBIx::Class::Storage' => {
517ba890 93 ignore => [qw/
94 schema
95 cursor
96 /]
7eb4ecc8 97 },
249963d4 98 'DBIx::Class::Schema' => {
517ba890 99 ignore => [qw/
100 setup_connection_class
101 /]
249963d4 102 },
32978f6e 103
104 'DBIx::Class::Schema::Versioned' => {
105 ignore => [ qw/
106 connection
517ba890 107 /]
00c937a2 108 },
737416a4 109
8c96bbc2 110 'DBIx::Class::Admin' => {
111 ignore => [ qw/
112 BUILD
113 /]
114 },
115
5f6a861d 116 'DBIx::Class::Storage::DBI::Replicated*' => {
117 ignore => [ qw/
118 connect_call_do_sql
119 disconnect_call_do_sql
120 /]
121 },
122
97f9f16e 123 'DBIx::Class::Admin::*' => { skip => 1 },
32978f6e 124 'DBIx::Class::ClassResolver::PassThrough' => { skip => 1 },
125 'DBIx::Class::Componentised' => { skip => 1 },
db29433c 126 'DBIx::Class::AccessorGroup' => { skip => 1 },
32978f6e 127 'DBIx::Class::Relationship::*' => { skip => 1 },
128 'DBIx::Class::ResultSetProxy' => { skip => 1 },
129 'DBIx::Class::ResultSourceProxy' => { skip => 1 },
9550c834 130 'DBIx::Class::ResultSource::*' => { skip => 1 },
32978f6e 131 'DBIx::Class::Storage::Statistics' => { skip => 1 },
eb7afcab 132 'DBIx::Class::Storage::DBI::Replicated::Types' => { skip => 1 },
737416a4 133
32978f6e 134# test some specific components whose parents are exempt below
32978f6e 135 'DBIx::Class::Relationship::Base' => {},
d5dedbd6 136 'DBIx::Class::SQLMaker::LimitDialects' => {},
737416a4 137
32978f6e 138# internals
d5dedbd6 139 'DBIx::Class::SQLMaker*' => { skip => 1 },
9fc20b28 140 'DBIx::Class::SQLAHacks*' => { skip => 1 },
32978f6e 141 'DBIx::Class::Storage::DBI*' => { skip => 1 },
142 'SQL::Translator::*' => { skip => 1 },
737416a4 143
32978f6e 144# deprecated / backcompat stuff
1b6fe47d 145 'DBIx::Class::Serialize::Storable' => { skip => 1 },
32978f6e 146 'DBIx::Class::CDBICompat*' => { skip => 1 },
147 'DBIx::Class::ResultSetManager' => { skip => 1 },
148 'DBIx::Class::DB' => { skip => 1 },
737416a4 149
32978f6e 150# skipped because the synopsis covers it clearly
151 'DBIx::Class::InflateColumn::File' => { skip => 1 },
cd122820 152
153# internal subclass, nothing to POD
154 'DBIx::Class::ResultSet::Pager' => { skip => 1 },
7eb4ecc8 155};
156
32978f6e 157my $ex_lookup = {};
158for my $string (keys %$exceptions) {
159 my $ex = $exceptions->{$string};
160 $string =~ s/\*/'.*?'/ge;
161 my $re = qr/^$string$/;
162 $ex_lookup->{$re} = $ex;
163}
164
165my @modules = sort { $a cmp $b } (Test::Pod::Coverage::all_modules());
166
7eb4ecc8 167foreach my $module (@modules) {
32978f6e 168 SKIP: {
169
6298a324 170 my ($match) =
171 first { $module =~ $_ }
32978f6e 172 (sort { length $b <=> length $a || $b cmp $a } (keys %$ex_lookup) )
173 ;
174
175 my $ex = $ex_lookup->{$match} if $match;
176
177 skip ("$module exempt", 1) if ($ex->{skip});
178
179 # build parms up from ignore list
180 my $parms = {};
181 $parms->{trustme} =
182 [ map { qr/^$_$/ } @{ $ex->{ignore} } ]
183 if exists($ex->{ignore});
184
185 # run the test with the potentially modified parm set
a109c954 186 Test::Pod::Coverage::pod_coverage_ok($module, $parms, "$module POD coverage");
32978f6e 187 }
7eb4ecc8 188}
32978f6e 189
190done_testing;