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

笑着哭i 提交于 2019-12-06 10:35:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/21919588/how-do-i-change-the-default-modulebuild-testmore-directory-from-lib-to-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!