Test-Apocalypse
view release on metacpan or search on metacpan
lib/Test/Apocalypse.pm view on Meta::CPAN
if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_APOCALYPSE} and $t->can( '_do_automated' ) and ! $t->_do_automated() ) {
diag( "Skipping $plugin ( for RELEASE_TESTING only )..." );
next;
}
# run it!
subtest $plugin => sub {
eval {
# TODO ignore annoying gpg warnings like 'WARNING: This key is not certified with a trusted signature!' at /usr/local/share/perl/5.18.2/Module/Signature.pm line 265.
no warnings qw(once);
local @Test::FailWarnings::ALLOW_FROM = ( 'Module::Signature' );
local $SIG{__WARN__} = \&Test::FailWarnings::handler;
$t->do_test();
};
if ( $@ ) {
# Sometimes we get a plain string, sometimes we get
# Error running Kwalitee: Test::Builder::Exception=HASH(0x3fa6078)
my $err = $@;
if ( $err->isa( 'Test::Builder::Exception' ) ) {
# TODO reach into T::B to get the actual skip reason
$err = Test::Builder->new->{Skip_All};
}
if ( $ENV{RELEASE_TESTING} or $ENV{PERL_APOCALYPSE} ) {
die "Error running $plugin: $err";
} else {
diag( "Error running $plugin: $err" );
}
# we need to manually intervene or we'll get this:
# Running DOSnewline...
# Running Dependencies...
# Child (Dependencies) exited without calling finalize()
# Failed test 'Dependencies'
# at /usr/local/share/perl/5.18.2/Test/Apocalypse.pm line 134.
# Error running Dependencies: Can't locate object method "new" via package "Version::Requirements" (perhaps you forgot to load "Version::Requirements"?) at /usr/local/share/perl/5.18.2/Test/Apocalypse/Dependencies.pm line 59.
# Running DirChecks...
# Error running DirChecks: You already have a child named (Dependencies) running at /usr/local/share/perl/5.18.2/Test/More.pm line 771.
done_testing();
}
};
}
done_testing();
return 1;
}
1;
__END__
=pod
=encoding UTF-8
=for :stopwords Apocalypse Niebur Ryan cpan testmatrix url annocpan anno bugtracker rt
cpants kwalitee diff irc mailto metadata placeholders metacpan apocal CPAN
AUTHORs al backend debian distro distros dists env hackish plugins
testsuite yml pm yay unicode blog precompiled =for stopwords ap cyclomatic
cal dist homebrew imo internet perltidy prefs prereq testrun
=head1 NAME
Test::Apocalypse - Apocalypse's favorite tests bundled into a simple interface
=head1 VERSION
This document describes v1.006 of Test::Apocalypse - released October 25, 2014 as part of Test-Apocalypse.
=head1 SYNOPSIS
#!/usr/bin/perl
use strict; use warnings;
use Test::More;
eval "use Test::Apocalypse";
if ( $@ ) {
plan skip_all => 'Test::Apocalypse required for validating the distribution';
} else {
is_apocalypse_here();
}
=head1 DESCRIPTION
This module greatly simplifies common author tests for modules heading towards CPAN. I was sick of copy/pasting
the tons of t/foo.t scripts + managing them in every distro. I thought it would be nice to bundle all of it into
one module and toss it on CPAN :) That way, every time I update this module all of my dists would be magically
updated!
This module respects the RELEASE_TESTING/AUTOMATED_TESTING env variable, if it is not set it will skip the entire
testsuite. Normally end-users should not run it; but you can if you want to see how bad my dists are, ha! The scheme
is exactly the same as the one Alias proposed in L<Test::XT> and in his blog post, L<http://use.perl.org/use.perl.org/_Alias/journal/38822.html>.
This module uses L<Module::Pluggable> to have custom "backends" that process various tests. We wrap them in a hackish
L<Test::Block> block per-plugin and it seems to work nicely. If you want to write your own, it should be a breeze
once you look at some of my plugins and see how it works. ( more documentation to come )
=head2 Usage
In order to use this, you would need to be familiar with the "standard" steps in order to fully exercise the testsuite.
There are a few steps we require, because our plugins need stuff to be prepared for them. For starters, you would need
a test file in your distribution similar to the one in SYNOPSIS. Once that is done and added to your MANIFEST and etc,
you can do this:
perl Build.PL # sets up the dist ( duh, hah )
./Build dist # makes the tarball ( so certain plugins can process it )
RELEASE_TESTING=1 ./Build test # runs the testsuite!
=head1 Methods
=head2 is_apocalypse_here()
This is the main entry point for this testsuite. By default, it runs every plugin in the testsuite. You can enable/disable
specific plugins if you desire. It accepts a single argument: a hashref or a hash. It can contain various options, but as of
now it only supports two options. If you try to use allow and deny at the same time, this module will throw an exception.
=head3 allow
Setting "allow" to a string or a precompiled regex will run only the plugins that match the regex. If passed a string, this module
will compile it via C<qr/$str/i>.
lib/Test/Apocalypse.pm view on Meta::CPAN
=over 4
=item * L<Test::Distribution>
This module was a plugin in this testsuite but I don't need it. All the functionality in it is already replicated in the plugins :)
=item * L<Test::Module::Used> and L<Test::Dependencies>
They were plugins in this testsuite but since I started coding with L<Moose>, they don't work! I've switched to my homebrew solution
utilizing L<Perl::PrereqScanner> which works nicely for me.
=item * L<Test::MyDeps>
Superseded by L<Test::DependentModules>. Also, I don't want to waste a lot of time on each testrun testing other modules!
=item * L<Test::NoTabs>
I always use tabs! :(
=item * L<Test::CheckManifest>
This was a buggy module that I dropped and is now using L<Test::DistManifest>
=item * L<Test::Dist>
This is pretty much the same thing as this dist ;)
=item * L<Test::PureASCII>
This rocks, as I don't care about unicode in my perl! ;)
=item * L<Test::LatestPrereqs>
This looks cool but we need to fiddle with config files? My OutdatedPrereqs test already covers it pretty well...
=item * L<Test::Pod::Content>
This is useful, but not everyone has the same POD layout. It would be too much work to try and generalize this...
=item * L<Test::GreaterVersion>
Since I never use CPAN, this is non-functional for me. However, it might be useful for someone?
=item * L<Test::Kwalitee>
This dist rocks, but it doesn't print the info nor utilize the extra metrics. My homebrew solution actually copied
a lot of code from this, so I have to give it props!
=item * L<Test::LoadAllModules>
This is very similar to L<Test::UseAllModules> but looks more complicated. Also, I already have enough tests that do that ;)
=item * L<Test::ModuleReady>
This looks like a nice module, but what it does is already covered by the numerous tests in this dist...
=item * L<Test::PerlTidy>
Br0ken install at this time... ( PerlCritic can do that! Need to investigate more... ) Also, all it does is... run your module
through perltidy and compare the outputs. Not that useful imo because I never could get perltidy to match my prefs :(
=item * L<Test::Install::METArequires>
This looks like a lazy way to do auto_install and potentially dangerous! Better to just use the prereq logic in Build.PL/Makefile.PL
=item * L<Test::Perl::Metrics::Simple>
This just tests your Cyclomatic complexity and was the starting point for my homebrew solution.
=back
=head1 SUPPORT
=head2 Perldoc
You can find documentation for this module with the perldoc command.
perldoc Test::Apocalypse
=head2 Websites
The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.
=over 4
=item *
MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
L<http://metacpan.org/release/Test-Apocalypse>
=item *
Search CPAN
The default CPAN search engine, useful to view POD in HTML format.
L<http://search.cpan.org/dist/Test-Apocalypse>
=item *
RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Apocalypse>
=item *
AnnoCPAN
The AnnoCPAN is a website that allows community annotations of Perl module documentation.
L<http://annocpan.org/dist/Test-Apocalypse>
=item *
( run in 1.349 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )