本文介绍了如何从“lib"更改默认的 Module::Build/Test::More 目录?到别的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此帖子中的目录和文件架构 关于 Perl 单元测试和代码覆盖率(顺便说一句非常有帮助),我将我将运行单元测试和代码覆盖率的文件复制到一个新的lib"目录中,它就像一个魅力!>

但是,我需要该模块在现有的脚本"目录中查找..

我梳理了关于CPAN,但我仍然收到找不到文件 lib/processBuildSubs.pm 错误

这是我目前所拥有的...

使用严格;使用模块::构建;我的 $newBuild = Module::Build->new(模块名称 =>'processBuildSubs',许可证 =>'perl',dist_abstract =>'processBuildSubs 单元测试',dist_author =>'me@myemail.com',build_requires =>{'测试::更多' =>'0.10',},);$newBuild->create_build_script();

更新!

也刚试过这个..

my $newBuild = Module::Build->new(模块名称 =>'scripts::processBuildSubs',pm_files =>{'processBuildSubs.pm' =>'lib/processBuildSubs.pm'},许可证 =>'perl',dist_abstract =>'processBuildSubs 单元测试',dist_author =>'me@myemail.com',build_requires =>{'测试::更多' =>'0.10',},);

我猜有些进展,它似乎在 lib/scripts/.. 中寻找,但仍然不是我需要的..

更新!

有点像黑客工作,但现在它对我有用..

#!/bin/bashmv 脚本库perl ./Build.plperl ./Build testcovermv 库脚本火狐cover_db/coverage.html

我运行此脚本来更改目录名称,运行测试/覆盖率并将目录名称改回...有人有更好的想法吗?

解决方案

您目前不能告诉 Module::Build 使用除lib"以外的另一个目录(我查看了 Module::Build 和 lib 似乎是相当硬编码的.)

您可以创建一个符号链接:

ln -s 脚本库

这将允许 Module::Build 找到它.

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?

解决方案

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.

这篇关于如何从“lib"更改默认的 Module::Build/Test::More 目录?到别的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 03:49