Dist::Zilla Plan

Just when you think Dist-Pen is gone its back again.

Now that I have my Dist::Zilla mostly worked out with all sorts of test goodies it is time that I buckle down and finish off and or clean up all my 'Automated' level test. As an side note, the term 'Automated' tests was a little confusing for me. I eventually figured out that by automated they (however they may be?) mean test that CPANTS will run. Normally these are the test in your 't' dir.

Myself I guess I must just be old school as I always called these module tests and it wasn't until I embarked on my Dist::Zilla trip that I have come to see the advantage of splitting your tests that really have noting to do with the function or you module, POD, spelling, Kwalitee etc, into the hand 'xt' dir.

We event have that handy 'dzil xtest' plug-in that you can pass in the test or tests you want to run, so you don't have to see the whole test suite go by. This leads me to a little sore point that we can not do the same with 'dzil test' so I have been watching all the sames tests run over and over again.

When you get down to it I cold see this being a good thing as if I am debugging and fixing something there is a chance that I might break something as I am fixing running the whole suite will find those breaks quickly.

Anyway on with my post. I was happily cleaning my test up, mostly adding in the correct # or tests, the odd use strict and some other small changes until I got to '20_dad_load.t' and it would not run;

t/20_dad_load.t ............. 1/47
#   Failed test 'use Data::Test;'
#   at t/20_dad_load.t line 14.
#     Tried to use 'Data::Test'.
#     Error:  Can't locate Data/Test.pm in @INC (you may need to install the Data::Test module) (@INC contains: ..\lib /home/scolesj/database-accessor/.build/vakxFsMN5C/blib/lib /home/scolesj/database-accessor/.build/vakxFsMN5C/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/20_dad_load.t line 14.
So something not right in the path and quick look in test case and I saw the problem

--use lib ('t/lib');
use lib ('..\lib');
seems still had this set up to run on my window box where I did not run them under Dist::zilla. I fixed this and I also notice I had

--    use_ok('Database::Accessor::Roles::DAD');
--    use_ok('Data::Test');
had those two as well so I cleaned up the test count

use MooseX::Test::Role;
--use Test::More tests => 47;
++use Test::More tests => 45;
and I get

t/19_function_expression.t .. ok
t/20_dad_load.t ............. ok
Now onto the next 't/30_view.t' and this one gave me no end of trouble. These where running in the window environment but here under Dist::Zilla things where going south.

t/20_dad_load.t ............. ok
t/30_view.t ................. Can't locate Data/Test.pm in @INC (you may need to install the Data::Test module) (@INC contains: ..\t\lib /home/scolesj/database-accessor/.build/2iIAXAdkzV/blib/lib /home/scolesj/database-accessor/.build/2iIAXAdkzV/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/30_view.t line 10.
I noticed the same error as before

--use lib ('t\lib');
++use lib ('..\t\lib');
which did not help

t/20_dad_load.t ............. ok
 Can't locate Database/Accessor/View.pm in @INC (you may need to install the Database::Accessor::View module) (@INC contains: t/lib /home/scolesj/database-accessor/.build/r4l6wZw6tN/blib/lib /home/scolesj/database-accessor/.build/r4l6wZw6tN/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /home/scolesj/database-accessor/.build/r4l6wZw6tN/blib/lib/Database/Accessor/Types.pm line 14.
Now this is one that really concerns me as I am not getting those embedded Database::Accessors classes in my path. I did notice I had this

--use Database::Accessor::DAD::Test;
which I took out as that should never be used directly.

t/20_dad_load.t ............. ok
RETRIEVE No Database::Accessor::Driver loaded for Data::Test Maybe you have to install a Database::Accessor::DAD::?? for it? at /home/scolesj/database-accessor/.build/WLPeq2DqMi/blib/lib/Database/Accessor.pm line 332.
# Looks like your test exited with 2 just after 1.
t/30_view.t ................. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests
Now the above one was a tricky one to figure out. Now I fixed this first by adding in

use Database::Accessor;
to Database::Accessor::DAD::Test in my 't/lib' dir but this was only a hack solution, but it did open my eyes to the real problem. The 'Database::Accessor::Role::DAD' is embedded in the Accessor.pm file so it is only visible to the class path when you use the file it is contained in. This is a problem if end users are going to create a DAD importing the DAD::Accessor parent directly would open up all sorts of problems so I bit the bullet and move that 'Role' into its own file which means this command

use Moose;
with(qw( Database::Accessor::Roles::DAD));
should find the class if it is in the path and that cleaned things up for me;

t/20_dad_load.t ............. ok
t/30_view.t .................ok
Great news is I did not break anything.


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