2011-05-10 140 views
0

這裏有測試的輸出。Test :: Builder :: Tester失敗測試失敗,爲什麼?

prove -lv t/02-fail.t 
t/02-fail.t .. 
not ok 1 
1..1 

# Failed test at t/02-fail.t line 15. 
# STDOUT is: 
# ok 1 - corpus/fail/FooBar.pm version 1.0.1 is valid 
# not ok 2 - corpus/fail/FooBarBaz.pm version is valid 
# 
# not: 
# ok 1 - corpus/fail/FooBar.pm version 1.0.1 is valid 
# 
# not ok 2 - corpus/fail/FooBarBaz.pm version is valid 
# 
# as expected 
# STDERR is: 
# # Failed test 'corpus/fail/FooBarBaz.pm version is valid' 
# # at /home/xenoterracide/projects/Test-HasValidVersion/lib/Test/HasValidVersion.pm line 60. 
# # corpus/fail/FooBarBaz.pm VERSION is not a valid verion 
# 
# not: 
# 
# as expected 
Failed 1/1 subtests 

Test Summary Report 
------------------- 
t/02-fail.t (Wstat: 0 Tests: 1 Failed: 1) 
    Failed test: 1 
Files=1, Tests=1, 0 wallclock secs (0.02 usr 0.01 sys + 0.04 cusr 0.01 csys = 0.08 CPU) 
Result: FAIL 

和測試本身

#!/usr/bin/perl 
use 5.006; 
use strict; 
use warnings; 
use Test::Builder::Tester; 
use Test::More; 
use Test::HasValidVersion qw(version_all_ok); 

test_out('ok 1 - corpus/fail/FooBar.pm version 1.0.1 is valid', 
    'not ok 2 - corpus/fail/FooBarBaz.pm version is valid' 
); 

version_all_ok('corpus/fail'); 

test_test; 
done_testing; 

(注:這裏的github repository測試代碼有一點點不同,但未能對同一模塊的鏈接沒有任何不同。如果。你克隆回購請確保你簽出提交daaab6a7c452958399f74150406915657f2cfa33作爲主分支正在更新)

我不知道爲什麼這是失敗的,它似乎是注入整條線docs別提。

有人可以幫助我糾正代碼,使其通過?

+0

也許你可以給作者發郵件。否則,你可以使用Test :: Tester來代替嗎? – dwarring 2011-05-10 06:06:33

+0

@snoopy我是作者......除非你的意思是Test :: Builder :: Tester的作者 – xenoterracide 2011-05-10 11:42:51

+0

是的,那就是我的意思 – dwarring 2011-05-11 01:31:01

回答

0

所以我需要做的是在代碼中添加一個test_fail(+4)。最終我切換到Test::Tester不必處理空白問題。

#!/usr/bin/perl 
use 5.006; 
use strict; 
use warnings; 
use Test::Builder::Tester; 
use Test::More; 
use Test::HasValidVersion qw(version_ok); 

test_out(
    'ok 1 - VERSION 1.0.1 in corpus/fail/FooBar.pm is valid', 
    'not ok 2 - validate VERSION in corpus/fail/FooBarBaz.pm', 
); 
test_fail(+4); 
test_diag('VERSION in corpus/fail/FooBarBaz.pm is not a valid version'); 

version_ok('corpus/fail/FooBar.pm'); 
version_ok('corpus/fail/FooBarBaz.pm'); 
# version_all_ok('corpus/fail'); 

test_test; 
done_testing; 

這裏有一個link to the fixed commit

0

您是否嘗試過將Test :: More和Test :: Builder :: Tester升級到最新版本?使用perl-5.10.1和perl-5.14.0-RC3這裏以及兩者的最新版本,我無法複製你的錯誤,使用你的git repo簽出(並修復了回購行中的明顯問題被顛倒過來)。

+0

我正在運行5.12.3以及任何最新的Test :: More,mike doherty幫助我知道了。我稍後會發布答案。顯然,如果你沒有使用提交的鏈接,它現在會通過,因爲它已經在master中修復了。 – xenoterracide 2011-05-13 01:27:40