gpt4 book ai didi

perl - 当我使用 Test::Harness::runtests 运行 Perl 模块测试时,为什么它们会失败?

转载 作者:行者123 更新时间:2023-11-28 20:17:21 27 4
gpt4 key购买 nike

我有一个 Test::More我们制作的模块的测试脚本。单独运行测试脚本时,它按预期工作。由于我们需要运行几个测试,我做了一个 Test::Harness运行所有脚本的文件。但是,从 Test::Harness 执行时runtests 脚本返回错误。

在调试过程中,我尝试使用 backtics 运行脚本并且成功了。所以 runtest 命令导致了错误。

线束的代码非常简单:

(perl) -w
use strict;
use warnings;
use Test::Harness;

my @tests = ('test1.pl', 'test2.pl', 'test3.pl');
runtests(@tests);

错误源 self 们使用的 cpan 模块,Pod::HtmlEasy .

我希望的解决方案是找到一种运行 Test::Harness 的方法没有得到错误。

测试的输出:

test1..........False [] range "\w-" in regex; marked by  line 20.Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 422,  line 20.Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 363,  line 22.False [] range "\w-" in regex; marked by  line 22.Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 488,  line 24.Use of uninitialized value in string ne at /app/perl/lib/Pod/HtmlEasy/Parser.pm line 363,  line 26.close() on unopened filehandle PODIN at /app/perl/lib/Pod/HtmlEasy.pm line 248.Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 318.(...)Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 396.test1..........ok 2/3close() on unopened filehandle PODIN at /app/perl/lib/Pod/HtmlEasy.pm line 248.Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 318.(...)Use of uninitialized value in concatenation (.) or string at /app/perl/lib/Pod/HtmlEasy.pm line 396.test1..........ok                                                      

最佳答案

为什么不让 Test::Harness 从命令行动态构建测试环境?

prove test*.pl

或者如果您按照标准将测试保存在 t/ 目录中:

prove -r t/

关于perl - 当我使用 Test::Harness::runtests 运行 Perl 模块测试时,为什么它们会失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1858935/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com