From b72fb699e9fe48a214b51820986cd2ee5f212d0a Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Thu, 8 Aug 2013 16:37:09 -0400 Subject: [PATCH] add release tests (fix minor stuff found by release tets) --- README.pod | 21 ++++--- dist.ini | 1 + lib/Mojolicious/Plugin/TtRenderer.pm | 10 ++- lib/Mojolicious/Plugin/TtRenderer/Engine.pm | 2 +- t/00-load.t | 10 ++- t/templates/Foo.pm | 4 +- xt/release/build_environment.t | 9 +++ xt/release/changes.t | 27 +++++++++ xt/release/eol.t | 14 +++++ xt/release/fixme.t | 18 ++++++ xt/release/no_tabs.t | 15 +++++ xt/release/pod.t | 15 +++++ xt/release/pod_coverage.t | 67 +++++++++++++++++++++ xt/release/pod_spelling_common.t | 15 +++++ xt/release/pod_spelling_system.t | 39 ++++++++++++ xt/release/release.yml | 34 +++++++++++ xt/release/strict.t | 15 +++++ 17 files changed, 298 insertions(+), 18 deletions(-) create mode 100644 xt/release/build_environment.t create mode 100644 xt/release/changes.t create mode 100644 xt/release/eol.t create mode 100644 xt/release/fixme.t create mode 100644 xt/release/no_tabs.t create mode 100644 xt/release/pod.t create mode 100644 xt/release/pod_coverage.t create mode 100644 xt/release/pod_spelling_common.t create mode 100644 xt/release/pod_spelling_system.t create mode 100644 xt/release/release.yml create mode 100644 xt/release/strict.t diff --git a/README.pod b/README.pod index c9f8de9..91e41ff 100644 --- a/README.pod +++ b/README.pod @@ -8,6 +8,15 @@ Mojolicious::Plugin::TtRenderer - Template Renderer Plugin for Mojolicious version 1.49 +=encoding utf-8 + +=begin stopwords + +Bjørn +Szász +Árpád + + =head1 SYNOPSIS L: @@ -17,7 +26,6 @@ L: L $self->plugin('tt_renderer'); - =head1 DESCRIPTION This plugin is a simple Template Toolkit renderer for L. @@ -25,8 +33,6 @@ Its defaults are usually reasonable, although for finer grain detail in configuration you may want to use L directly. -=encoding utf-8 - =head1 OPTIONS These are the options that can be passed in as arguments to this plugin. @@ -66,7 +72,6 @@ Here is the same example using the full L app form: } These options will be used if you do not override them: - =over 4 =item INCLUDE_PATH @@ -91,7 +96,7 @@ C C<128> -=item RELATIZE +=item RELATIVE C<1> (true) @@ -110,7 +115,6 @@ is equivalent to except in the first example relative paths are relative to the L app's home directory (C<$app-Ehome>). - =head1 STASH =head2 h @@ -118,13 +122,11 @@ app's home directory (C<$app-Ehome>). Helpers are available via the C entry in the stash. go back to index - =head2 c The current controller instance can be accessed as C. I see you are requesting a document from [% c.req.headers.host %]. - =head1 EXAMPLES L example: @@ -189,7 +191,6 @@ L example: These are also included with the C distribution, including the support files required for the full L app example. - =head1 SEE ALSO L, @@ -197,6 +198,8 @@ L, L, L. +=end stopwords + =head1 AUTHOR original author: Ask Bjørn Hansen diff --git a/dist.ini b/dist.ini index d2d36f2..94d65d9 100644 --- a/dist.ini +++ b/dist.ini @@ -8,6 +8,7 @@ copyright_holder = Ask Bjørn Hansen version = 1.49 [@Author::Plicease] +release_tests = 1 [Prereqs] Mojolicious = 3.33 diff --git a/lib/Mojolicious/Plugin/TtRenderer.pm b/lib/Mojolicious/Plugin/TtRenderer.pm index 8c137ae..1b7457a 100644 --- a/lib/Mojolicious/Plugin/TtRenderer.pm +++ b/lib/Mojolicious/Plugin/TtRenderer.pm @@ -29,6 +29,14 @@ __END__ =encoding utf-8 +=begin stopwords + +Bjørn +Szász +Árpád + +=cut + =head1 SYNOPSIS L: @@ -110,7 +118,7 @@ C C<128> -=item RELATIZE +=item RELATIVE C<1> (true) diff --git a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm index acfa507..1a81ccc 100644 --- a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm +++ b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm @@ -294,7 +294,7 @@ object. When used the INCLUDE_PATH will be set to A hash reference of options that are passed to Template->new(). Note that if you specify an C through this option it will remove the DATA section templates from your path. A better way to specify an C if you also -want to use DATA section templates it by manipulting the L +want to use DATA section templates it by manipulating the L path. =item cache_dir diff --git a/t/00-load.t b/t/00-load.t index 99bdb96..ab61fa8 100644 --- a/t/00-load.t +++ b/t/00-load.t @@ -1,9 +1,7 @@ -#!perl - +use strict; +use warnings; use Test::More tests => 2; -BEGIN { - use_ok( 'Mojolicious::Plugin::TtRenderer' ); - use_ok( 'Mojolicious::Plugin::TtRenderer::Engine' ); -} +use_ok( 'Mojolicious::Plugin::TtRenderer' ); +use_ok( 'Mojolicious::Plugin::TtRenderer::Engine' ); diff --git a/t/templates/Foo.pm b/t/templates/Foo.pm index e22fdde..1c5e267 100644 --- a/t/templates/Foo.pm +++ b/t/templates/Foo.pm @@ -1,5 +1,7 @@ package - Foo; + Foo; +use strict; +use warnings; 1; __DATA__ diff --git a/xt/release/build_environment.t b/xt/release/build_environment.t new file mode 100644 index 0000000..82bb61c --- /dev/null +++ b/xt/release/build_environment.t @@ -0,0 +1,9 @@ +use strict; +use warnings; +use Test::More tests => 1; + +SKIP: { + eval q{ use Dist::Zilla::PluginBundle::Author::Plicease }; + skip '[@Plicease] is not installed', 1 if $@; + ok $Dist::Zilla::PluginBundle::Author::Plicease::VERSION >= 0.7, '[@Plicease] >= 0.7'; +} diff --git a/xt/release/changes.t b/xt/release/changes.t new file mode 100644 index 0000000..88cf462 --- /dev/null +++ b/xt/release/changes.t @@ -0,0 +1,27 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::CPAN::Changes' + unless eval q{ use Test::CPAN::Changes; 1 }; +}; +use Test::CPAN::Changes; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +do { + my $old = \&Test::Builder::carp; + my $new = sub { + my($self, @messages) = @_; + return if $messages[0] =~ /^Date ".*" is not in the recommend format/; + $old->($self, @messages); + }; + no warnings 'redefine'; + *Test::Builder::carp = $new; +}; + +changes_file_ok; + +done_testing; diff --git a/xt/release/eol.t b/xt/release/eol.t new file mode 100644 index 0000000..3f2e816 --- /dev/null +++ b/xt/release/eol.t @@ -0,0 +1,14 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::EOL' + unless eval q{ use Test::EOL; 1 }; +}; +use Test::EOL; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +all_perl_files_ok(grep { -e $_ } qw( bin lib t Makefile.PL )); diff --git a/xt/release/fixme.t b/xt/release/fixme.t new file mode 100644 index 0000000..7f7ee20 --- /dev/null +++ b/xt/release/fixme.t @@ -0,0 +1,18 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Fixme' + unless eval q{ use Test::Fixme; 1 }; +}; +use Test::Fixme 0.07; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +run_tests( + match => qr/FIXME/, + where => [ grep { -e $_ } qw( bin lib t Makefile.PL )], +); + diff --git a/xt/release/no_tabs.t b/xt/release/no_tabs.t new file mode 100644 index 0000000..0a6d2b6 --- /dev/null +++ b/xt/release/no_tabs.t @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::NoTabs' + unless eval q{ use Test::NoTabs; 1 }; +}; +use Test::NoTabs; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); + diff --git a/xt/release/pod.t b/xt/release/pod.t new file mode 100644 index 0000000..2603675 --- /dev/null +++ b/xt/release/pod.t @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Pod' + unless eval q{ use Test::Pod; 1 }; +}; +use Test::Pod; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +all_pod_files_ok( grep { -e $_ } qw( bin lib )); + diff --git a/xt/release/pod_coverage.t b/xt/release/pod_coverage.t new file mode 100644 index 0000000..7095883 --- /dev/null +++ b/xt/release/pod_coverage.t @@ -0,0 +1,67 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Pod::Coverage' + unless eval q{ use Test::Pod::Coverage; 1 }; + plan skip_all => 'test requires YAML' + unless eval q{ use YAML; 1; }; +}; +use Test::Pod::Coverage; +use YAML qw( LoadFile ); +use FindBin; +use File::Spec; + +my $config_filename = File::Spec->catfile( + $FindBin::Bin, 'release.yml' +); + +my $config; +$config = LoadFile($config_filename) + if -r $config_filename; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +my @private_classes; +my %private_methods; + +foreach my $private (@{ $config->{pod_coverage}->{private} }) +{ + my($class,$method) = split /#/, $private; + if(defined $class && $class ne '') + { + my $regex = eval 'qr{^' . $class . '$}'; + if(defined $method && $method ne '') + { + push @private_classes, { regex => $regex, method => $method }; + } + else + { + push @private_classes, { regex => $regex, all => 1 }; + } + } + elsif(defined $method && $method ne '') + { + $private_methods{$_} = 1 for split /,/, $method; + } +} + +my @classes = all_modules; + +plan tests => scalar @classes; + +foreach my $class (@classes) +{ + SKIP: { + my($is_private_class) = map { 1 } grep { $class =~ $_->{regex} && $_->{all} } @private_classes; + skip "private class: $class", 1 if $is_private_class; + + my %methods = map {; $_ => 1 } map { split /,/, $_->{method} } grep { $class =~ $_->{regex} } @private_classes; + $methods{$_} = 1 for keys %private_methods; + + my $also_private = eval 'qr{^' . join('|', keys %methods ) . '$}'; + + pod_coverage_ok $class, { also_private => [$also_private] }; + }; +} + diff --git a/xt/release/pod_spelling_common.t b/xt/release/pod_spelling_common.t new file mode 100644 index 0000000..4ee3dcf --- /dev/null +++ b/xt/release/pod_spelling_common.t @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Pod::Spelling::CommonMistakes' + unless eval q{ use Test::Pod::Spelling::CommonMistakes; 1 }; +}; +use Test::Pod::Spelling::CommonMistakes; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +# FIXME test files in bin too. +all_pod_files_ok; diff --git a/xt/release/pod_spelling_system.t b/xt/release/pod_spelling_system.t new file mode 100644 index 0000000..eac020c --- /dev/null +++ b/xt/release/pod_spelling_system.t @@ -0,0 +1,39 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Spelling' + unless eval q{ use Test::Spelling; 1 }; + plan skip_all => 'test requires YAML' + unless eval q{ use YAML; 1; }; +}; +use Test::Spelling; +use YAML qw( LoadFile ); +use FindBin; +use File::Spec; + +my $config_filename = File::Spec->catfile( + $FindBin::Bin, 'release.yml' +); + +my $config; +$config = LoadFile($config_filename) + if -r $config_filename; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +add_stopwords(@{ $config->{pod_spelling_system}->{stopwords} }); +add_stopwords(); +all_pod_files_spelling_ok; + +__DATA__ +Plicease +stdout +stdin +subref +loopback +username +os +Ollis +Mojolicious +plicease diff --git a/xt/release/release.yml b/xt/release/release.yml new file mode 100644 index 0000000..f92c3ee --- /dev/null +++ b/xt/release/release.yml @@ -0,0 +1,34 @@ +--- +pod_spelling_system: + # list of words that are spelled correctly + # (regardless of what spell check thinks) + stopwords: + - Bethke + - Cosimo + - Crowther + - Holm + - Htbaa + - Kitover + - Magnus + - Mojo + - Ramberg + - Streppone + - Vuets + - dir + - giftnuss + - mojo + - namespace + - renderer + - spleenjack + - vti + - app's + - renderer's + - Toolkit's + - Fayland + +pod_coverage: + # format is "Class#method" or "Class", regex allowed + # for either Class or method. + private: + - Mojolicious::Plugin::TtRenderer#register + - Mojolicious::Plugin::TtRenderer::Engine#tt diff --git a/xt/release/strict.t b/xt/release/strict.t new file mode 100644 index 0000000..2dbad08 --- /dev/null +++ b/xt/release/strict.t @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + plan skip_all => 'test requires Test::Strict' + unless eval q{ use Test::Strict; 1 }; +}; +use Test::Strict; +use FindBin; +use File::Spec; + +chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); + +all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); +