perlunit-testingdevel-covermodule-buildtest-more

How do I change the default Module::Build / Test::More directory from "lib" to something else?


Using the directory and file architecture in this Post on Perl Unit testing and Code Coverage (which btw was VERY helpful), I copied the files I'll be running unit tests and code coverage on into a new "lib" directory and it works like a charm!

However, I need the module to look in an existing "scripts" directory..

I have combed through the Module::Build documentation on CPAN, but I still get a Can't find file lib/processBuildSubs.pm error

Here's what I have thus far...

use strict;
use Module::Build;


my $newBuild = Module::Build->new(

    module_name         => 'processBuildSubs',
    license             => 'perl',
    dist_abstract       => 'processBuildSubs Unit Test',
    dist_author         => 'me@myemail.com',
    build_requires      => {
           'Test::More' => '0.10',
    },

);

$newBuild->create_build_script();

UPDATE!

Also just tried this..

my $newBuild = Module::Build->new(

    module_name     => 'scripts::processBuildSubs',
    pm_files        => {'processBuildSubs.pm' => 'lib/processBuildSubs.pm'},
    license         => 'perl',
    dist_abstract       => 'processBuildSubs Unit Test',
    dist_author         => 'me@myemail.com',
    build_requires  => {
        'Test::More' => '0.10',
    },

);

Some progress I guess, it seems to be looking in lib/scripts/.., still not quite what I need though..

UPDATE!

Sort of a hack job, but for now it does the trick for me..

#!/bin/bash

mv scripts lib
perl ./Build.pl
perl ./Build testcover
mv lib scripts
firefox cover_db/coverage.html

I run this script to change the directory name, run the tests/coverage and change the directory name back... Anyone have better ideas?


Solution

  • You can't currently tell Module::Build to use another directory other than "lib" (I looked at the source code for Module::Build and lib seems to be pretty hard coded.)

    You could create a symlink:

    ln -s scripts lib
    

    And this would allow Module::Build to find it.