Dist::Zilla In The Sky

Its plow though some more test plug-ins day again here in the Dist-Pen.

So in my last post had found one plug-in that was useful, today I hope to find another from this list of Dist::Zilla::Test plug-in


CPAN::Changes
A 'Release' test case that will run 'Test::CPAN::Changes' so in-effect does the same thing as 'Dist::Zilla::Plugin::Test::CheckChanges' not one I am going to use.https://www.cpan.org/modules/04pause.html#before

CPAN::Meta::JSON

A 'Release' test case that will run 'Test::CPAN::Meta::JSON'. Now in my distribution I am using the MetaJSON plug-in which generates my Meta.Json so I see no need for this one either.

CreateFromMojoTemplates
So a quick look here I see this is a 'deprecated' test and has been replace by 'Dist::Zilla::Plugin::Stenciller::Mojolicious' which actually is a bug as it leads no where my best guess it should point to 'Dist::Zilla::Plugin::Stenciller::MojoliciousTests'. Not for me today as it is a very specific test case for 'Stenciller'. Well at least I found a bug.

DiagINC
This is the fist 'Automated' test case I found. It adds in the 'Test::DiagINC' to all of your test cases under '/t' and is intended to give feedback from the Automated testing process, or any environment where 'AUTOMATED_TESTIN' is set, if something goes south. So this one dose not run when a user tries to install or with the 'Release' and 'Author' tests or which is neat. I am going to keep an eye on this one as I might include it in a later version once my baase code makes it to CPAN and is nicely smoked by CPANTS

DistManifest
Another 'Release' test case that will run 'Test::DistManifest' so the same again as Dist::Zilla::Plugin::Test::CheckManifest with a little difference under the hood. I guess the author of this one should of read the little before section up on the PAUSE FAQ

EOF

Now here is an 'Author' level test I can use. It uses Test::EOF to ensure that your files end correctly. Might sound like a silly test but will help me out as I flip between Windows, Mac and Linux quite and editors quite often when I am working on a project and I have ticked some off in the past when a doc of mine ends like this


1:
^R
^M

Lets give it a try shall we by first installing it and then add this;

...
[Test::CleanNamespaces]
++[Test::EOF]
++strict = 1
[Git::Check] 

to the '.ini' file, notice I set an attribute on it to strict just to see what happens. As this is an 'Author' level pregame I am going to use 'dzil xtest author';

xt/author/eof.t ............... 1/?
# Failed test 'Not enough line breaks (had 0, wanted 1) at the end of /home/scolesj/database-accessor/.build/sy1eG9rN2O/t/39_sorts.t'
# at /usr/local/share/perl/5.18.2/Test/EOF.pm line 41.

# Failed test 'Not enough line breaks (had 0, wanted 1) at the end of /home/scolesj/database-accessor/.build/sy1eG9rN2O/t/lib/Test/Database/Accessor/Utils.pm'
# at /usr/local/share/perl/5.18.2/Test/EOF.pm line 41.
# Looks like you failed 24 tests of 43.
xt/author/eof.t ............... Dubious, test returned 24 (wstat 6144, 0x1800)
Failed 24/43 subtests

Ok that caught a number of items. Lest see if I can fix that last one in 't/lib/Test/Database/Accessor/Utils.pm' by just adding a line break at the end of the file and I run again and get


Failed test 'Too many line breaks (had 3, wanted 1) at the end of /home/scolesj/database-accessor/.build/XEgiWqCV3D/t/12_element.t '
# at /usr/local/share/perl/5.18.2/Test/EOF.pm line 41.
# Looks like you failed 23 tests of 43.

Passed that one so this one is a keeper.


EOL

Another 'Author' level test utilizing Tests::EOL. This one is looking for end of line a mistakes, I know I have made in the past. as I have seen some of my own code come up with a 'carriage return' like this


my $watermelon = Melon->new('honey-dew');^M

Again is is a good one for me to try. I noticed in the POD of EOF I should run this one first, if I want to keep a '/n' at the end of the file, so after and install I added this;

[Test::CleanNamespaces]
++[Test::EOL]
[Test::EOF]
strict = 1

to my '.ini' and with 'dzil xtest author' again I get

xt/author/eol.t ............... 1/?
# Failed test 'No incorrect line endings in 'lib/Database/Accessor.pm' on line 406: [\s] '
# at xt/author/eol.t line 46.
# Problem Lines:
# line 406: [\s] : [\s][\s][\s][\s]package[\s]

# Failed test 'No incorrect line endings in 't/lib/Test/Database/Accessor/Utils.pm' on line 28: [\s][\s][\s][\s][\s] '
# at xt/author/eol.t line 46.
# Problem Lines:
# line 28: [\s][\s][\s][\s][\s] : [\s][\s][\s][\s][\s]

# Failed test 'No incorrect line endings in 't/test.pl' on line 1: [\s] '
# at xt/author/eol.t line 46.
# Problem Lines:
# line 1: [\s] : #!perl[\s]
# Looks like you failed 33 tests of 34.
xt/author/eol.t ............... Dubious, test returned 33 (wstat 8448, 0x2100)
Failed 33/34 subtests


Opps! not in very good shape. So I clean up '/lib/Test/Database/Accessor/Utils.pm' and run my tests again, (well actually four or was it five test runs to get them all ??), and I get

...
# Failed test 'No incorrect line endings in 't/test.pl' on line 1: [\s] '
# at xt/author/eol.t line 46.
# Problem Lines:
# line 1: [\s] : #!perl[\s]
# Looks like you failed 32 tests of 34.
xt/author/eol.t ............... Dubious, test returned 32 (wstat 8192, 0x2000)
Failed 32/34 subtests

One down 33 to go. Now just as a hoot I went into that file and added in a 'Carriage Return' like this

use strict;
--use warnings;
++use warnings;^M
sub deep_element {

I re-ran the test case and got

# Failed test 'No incorrect line endings in 't/lib/Test/Database/Accessor/Utils.pm' on line 11: [\r] '
# at xt/author/eol.t line 46.
# Problem Lines:
...

So it caught that nasty ^M. Good.

All in all a good day today, added two more useful plug-ins to my distribution, so I hope I never have to hear 'You left in a ^M in your CPAN upload' again and found a bug in someone elses program for once.

5b1de279afb32c47c4227149ee699a74.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations