WHAT?
Dist-Zilla-Tester-DieHard (or shortly DieHard) is a Dist::Zilla testing tool, it
extends standard Dist::Zilla::Tester. If Dist::Zilla dies in construction,
DieHard survives itself and saves the logger to let you analyze the messages.
WHY?
Usually I test my Dist::Zilla plugins in such a way:
...
use Dist::Zilla::Tester;
use Test::Deep qw{ cmp_deeply };
use Test::Fatal;
use Test::More;
my $tzil = Builder->from_config( ... );
my $exception = exception { $tzil->build(); };
if ( $expected_success ) {
is( $exception, undef, 'status' );
} else {
like( $exception, qr{...}, 'status' );
};
cmd_deeply( $tzil->log_messages, $expected_messages, 'log messages' );
...
The approach works well, until Dist::Zilla dies in from_config (e. g. if a
plugin throws an exception in its construction).
A straightforward attempt to catch exception thrown in from_config:
my $tzil;
my $exception = exception { $tzil = Builder->from_config( … ); };
if ( $expected_success ) {
is( $exception, undef, 'status' );
} else {
like( $exception, qr{…}, 'status' );
};
works but… from_config dies leaving $tzil undefined, log_messages method is
called on undefined value definitely fails:
cmd_deeply( $tzil->log_messages, $expected_messages, 'log messages' );
# ^^^^^^^^^^^^^^^^^^^
# Oops: $tzil undefined.
Dist::Zilla dies, and all the messages logged by either Dist::Zilla or its
plugins are buried with Dist::Zilla.
Using Dist::Zilla::Tester::DieHard instead of regular Dist::Zilla::Tester solves
this problem: even if a plugin throws an exception in constructor,
Builder->from_config does not die but returns a "survivor" object which can be
used to retrieve log messages.
NAMING
perl-Dist-Zilla-Tester-DieHard is official software name.
However, in Perl world prefix "perl-" is redundant and not used. For example, on
meta::cpan this software is named as
Dist-Zilla-Tester-DieHard. In the rest of the documentation shortened name
Dist-Zilla-Tester-DieHard is used as synonym for full name
perl-Dist-Zilla-Tester-DieHard. We are in the Perl world, aren't we?
You may notice that name may be spelled with dashes (Dist-Zilla-Tester-DieHard)
or with double colons (Dist::Zilla::Tester::DieHard). Strictly speaking, there
is difference: the first one is software name, while the second is name of Perl
package, but often these names are interchangeable especially if software
consists of single package.
FORMS
You may face Dist-Zilla-Tester-DieHard in *source* or *distribution* forms.
If you are going to die hard Dist::Zilla, but save the messages, you will likely
be interested in *using* Dist-Zilla-Tester-DieHard *distribution*. If you are
going to *develop* (or *hack*) the Dist-Zilla-Tester-DieHard itself, you will
likely need the *source*, not distribution.
Since Perl is an interpreting language, modules in the distribution *look* like
sources. Actually, they are Perl source files. But they are not *actual*
sources, because they are *built* (preprocessed or generated) by Dist-Zilla.
How to distinguish source and distribution:
* Source may contain Mercurial files and directories .hgignore, .hgtags, .hg/,
while distribution should not.
* Source should contain dist.ini file, while distribution may not.
* Source should *not* contain xt/ directory, while distribution should.
* Name of source directory does *not* include version (e. g.
Dist-Zilla-Tester-DieHard), while name of distribution does (e. g.
Dist-Zilla-Tester-DieHard-v0.7.1).
SOURCE
Dist-Zilla-Tester-DieHard source is in Mercurial repository hosted on
fedorapeople.org. To clone the entire repository:
$ hg clone https://vandebugger.fedorapeople.org/hg/perl-Dist-Zilla-Tester-DieHard
Source Files
Dist-Zilla-Tester-DieHard source files usually include a comment near the top of
the file:
This file is part of perl-Dist-Zilla-Tester-DieHard.
Not all source files are included into distribution. Some source files are used
at distribution build time only, and not required for installation.
DISTRIBUTION
Dist-Zilla-Tester-DieHard distributions are published on CPAN
.
Generated Files
Distribution may contain files preprocessed or generated by Dist-Zilla and its
plugins. Some generated files are made from Dist-Zilla-Tester-DieHard source,
but some are generated from third-party templates. Files generated from
third-party templates usually include a comment near the top of the file:
This file was generated with NAME
(where *NAME* is a name of the plugin generated the file). Such files are *not*
part of Dist-Zilla-Tester-DieHard source, and Dist-Zilla-Tester-DieHard
copyright and license are not applicable to such files.
INSTALLING
With cpanm
cpanm tool is (probably) the easiest way to install distribution. It automates
downloading, building, testing, installing, and uninstalling.
To install the latest version from CPAN:
$ cpanm Dist::Zilla::Tester::DieHard
To install a specific version (e. g. *v0.7.1*) from CPAN:
$ cpanm Dist::Zilla::Tester::DieHard@v0.7.1
To install locally available distribution (e. g. previously downloaded from CPAN
or built from sources):
$ cpanm ./Dist-Zilla-Tester-DieHard-v0.7.1.tar.gz
To uninstall the distribution:
$ cpanm -U Dist::Zilla::Tester::DieHard
Manually
To install distribution tarball manually (let us assume you have version
*v0.7.1* of the distribution):
$ tar xaf Dist-Zilla-Tester-DieHard-v0.7.1.tar.gz
$ cd Dist-Zilla-Tester-DieHard-v0.7.1
$ perl Build.PL
$ ./Build build
$ ./Build test
$ ./Build install
See Also
How to install CPAN modules
HACKING
For hacking, you will need Mercurial, Perl interpreter and Dist-Zilla (with some
plugins), and likely cpanm to install missed parts.
Clone the repository first:
$ hg clone https://vandebugger.fedorapeople.org/hg/perl-Dist-Zilla-Tester-DieHard
$ cd perl-Dist-Zilla-Tester-DieHard
To build a distribution from the source, run:
$ dzil build
If required Dist-Zilla plugins are missed, dzil tool will warn you and show the
command to install all the required plugins, e. g.:
Required plugin Dist::Zilla::Plugin::Test::EOL isn't installed.
Run 'dzil authordeps' to see a list of all required plugins.
You can pipe the list to your CPAN client to install or update them:
dzil authordeps --missing | cpanm
To run the tests:
$ dzil test
To run all the tests, including release tests:
$ dzil test --release
To install the distribution:
$ dzil install
or
$ cpanm ./Dist-Zilla-Tester-DieHard-VERSION.tar.gz
where *VERSION* is a version of built distribution.
To clean the directory:
$ dzil clean
DOCUMENTATION
Online
The easiest way is browsing the documentation online at meta::cpan
.
Locally Installed
If you have the distribution installed, use perldoc tool to browse locally
installed documentation:
$ perldoc Dist::Zilla::Tester::DieHard::Manual
$ perldoc Dist::Zilla::Tester::DieHard
Built from Source
Build Dist-Zilla-Tester-DieHard first (see "HACKING"), then:
$ cd Dist-Zilla-Tester-DieHard-VERSION
$ perldoc Dist::Zilla::Tester::DieHard::Manual
$ perldoc Dist::Zilla::Tester::DieHard
where *VERSION* is a version of built distribution.
FEEDBACK
CPAN Request Tracker
The quickest way to report a bug in Dist-Zilla-Tester-DieHard is by sending
email to bug-Dist-Zilla-Tester-DieHard [at] rt.cpan.org.
CPAN request tracker can be used via web interface also:
Browse bugs
Browsing bugs does not require authentication.
Report bugs
You need to be a CPAN author, have a BitCard
account, or OpenID in order to report bugs via the web interface.
(On 2015-04-27 I have logged in successfully with my LiveJournal OpenID, but
my Google OpenID did not work for CPAN. I did not check other OpenID
providers.)
Send Email to Author
As a last resort, send email to author: Van de Bugger .
Please start message subject with "perl-Dist-Zilla-Tester-DieHard:".
GLOSSARY
CPAN
Comprehensive Perl Archive Network, a large collection of Perl software and
documentation. See cpan.org , What is CPAN?
.
Distribution
Tarball, containing Perl modules and accompanying files (documentation,
metainfo, tests). Usually distributions are uploaded to CPAN, and can be
installed with dedicated tools (cpan, cpanm, and others).
Module
Perl library file, usually with .pm suffix. Usually contains one package.
See perlmod .
Package
Perl language construct. See package
and perlmod
.