1

这是捕获的命令和标准输出:

$perlcritic --gentle . | nl -nln | sed 's/\(.*source OK\)$/ok \1/' | sed '/source OK$/!s/^.*$/not ok &/' | tee perlcritic_tap.results.1

输出:

not ok 1        Bareword file handle opened at line 184, column 17.  See pages 202,204 of PBP.  (Severity: 5)
not ok 2        Two-argument "open" used at line 184, column 17.  See page 207 of PBP.  (Severity: 5)
not ok 3        Bareword file handle opened at line 311, column 9.  See pages 202,204 of PBP.  (Severity: 5)
not ok 4        Two-argument "open" used at line 311, column 9.  See page 207 of PBP.  (Severity: 5)
not ok 5        Bareword file handle opened at line 371, column 12.  See pages 202,204 of PBP.  (Severity: 5)
not ok 6        Two-argument "open" used at line 371, column 12.  See page 207 of PBP.  (Severity: 5)
not ok 7        Bareword file handle opened at line 390, column 13.  See pages 202,204 of PBP.  (Severity: 5)
not ok 8        Two-argument "open" used at line 390, column 13.  See page 207 of PBP.  (Severity: 5)
not ok 9        Bareword file handle opened at line 522, column 5.  See pages 202,204 of PBP.  (Severity: 5)
not ok 10       Two-argument "open" used at line 522, column 5.  See page 207 of PBP.  (Severity: 5)
not ok 11       Bareword file handle opened at line 615, column 10.  See pages 202,204 of PBP.  (Severity: 5)
not ok 12       Two-argument "open" used at line 615, column 10.  See page 207 of PBP.  (Severity: 5)

验证文件内容:

more perlcritic_tap.results.1 

not ok 1        Bareword file handle opened at line 184, column 17.  See pages 202,204 of PBP.  (Severity: 5)
not ok 2        Two-argument "open" used at line 184, column 17.  See page 207 of PBP.  (Severity: 5)
not ok 3        Bareword file handle opened at line 311, column 9.  See pages 202,204 of PBP.  (Severity: 5)
not ok 4        Two-argument "open" used at line 311, column 9.  See page 207 of PBP.  (Severity: 5)
not ok 5        Bareword file handle opened at line 371, column 12.  See pages 202,204 of PBP.  (Severity: 5)
not ok 6        Two-argument "open" used at line 371, column 12.  See page 207 of PBP.  (Severity: 5)
not ok 7        Bareword file handle opened at line 390, column 13.  See pages 202,204 of PBP.  (Severity: 5)
not ok 8        Two-argument "open" used at line 390, column 13.  See page 207 of PBP.  (Severity: 5)
not ok 9        Bareword file handle opened at line 522, column 5.  See pages 202,204 of PBP.  (Severity: 5)
not ok 10       Two-argument "open" used at line 522, column 5.  See page 207 of PBP.  (Severity: 5)
not ok 11       Bareword file handle opened at line 615, column 10.  See pages 202,204 of PBP.  (Severity: 5)
not ok 12       Two-argument "open" used at line 615, column 10.  See page 207 of PBP.  (Severity: 5)

现在附加 TAP 格式的顶部:

echo 1.. `wc -l < perlcritic_tap.results.1` | cat - perlcritic_tap.results.1  > perlcritic_tap.results

perlcritic_tap.results:

1.. 12
not ok 1        Bareword file handle opened at line 184, column 17.  See pages 202,204 of PBP.  (Severity: 5)
not ok 2        Two-argument "open" used at line 184, column 17.  See page 207 of PBP.  (Severity: 5)
not ok 3        Bareword file handle opened at line 311, column 9.  See pages 202,204 of PBP.  (Severity: 5)
not ok 4        Two-argument "open" used at line 311, column 9.  See page 207 of PBP.  (Severity: 5)
not ok 5        Bareword file handle opened at line 371, column 12.  See pages 202,204 of PBP.  (Severity: 5)
not ok 6        Two-argument "open" used at line 371, column 12.  See page 207 of PBP.  (Severity: 5)
not ok 7        Bareword file handle opened at line 390, column 13.  See pages 202,204 of PBP.  (Severity: 5)
not ok 8        Two-argument "open" used at line 390, column 13.  See page 207 of PBP.  (Severity: 5)
not ok 9        Bareword file handle opened at line 522, column 5.  See pages 202,204 of PBP.  (Severity: 5)
not ok 10       Two-argument "open" used at line 522, column 5.  See page 207 of PBP.  (Severity: 5)
not ok 11       Bareword file handle opened at line 615, column 10.  See pages 202,204 of PBP.  (Severity: 5)
not ok 12       Two-argument "open" used at line 615, column 10.  See page 207 of PBP.  (Severity: 5)

但我仍然无法让 Jenkins 识别 TAP 文件格式,并且出现错误:

Found matching files but did not find any TAP results.
4

3 回答 3

4

这是插件中的一个错误。即使您指定了不同的文件扩展名,它也会查找 *.tap(插件开发人员在编写该代码时可能已经喝醉了)。我已经为此填写了一个问题,但是您可以让您的结果在当前版本的 TAP 插件(1.6)中工作,执行以下操作:

1)正如你提到的,删除TAP计划中的空间(即:1..12而不是1..12)。,

2) 不要写 perlcritic_tap.results,而是使用 perlcritic_tap.tap。

我正在为此准备一个补丁,并将在几个小时内发布。在 Jenkins 中同步更新站点需要一段时间,但希望到周一上班时您应该能够毫无问题地使用该插件。

你有任何需要都请告诉我。我在这里很新,并且没有足够的业力来添加更多链接,但是我使用您的 TAP 文件将插件的一些屏幕截图附加到 Jenkins JIRA 中的问题中;-)

一切顺利,-kinow

于 2012-10-20T21:21:24.243 回答
3

我认为这是您计划中的额外空间。请改用 1..12。(..后面没有空格)

我已经使用了 Jenkins JUnit 插件:

证明 --formatter=TAP::Formatter::JUnit

于 2012-10-13T00:43:56.753 回答
1

在对Jenkins 进行测试时,我使用JUnit TAP 工具取得了成功。最新版本也允许您通过环境变量将测试分组到包中。

export JUNIT_OUTPUT_FILE="$WORKSPACE/junit_app.xml"
export JUNIT_PACKAGE="app"
cd $WORKSPACE/Offer; prove -I ./lib -v --harness=TAP::Harness::JUnit

维护者似乎反应灵敏(包 env-var 是我实现的一个小补丁),所以如果有任何限制,您应该能够纠正它们。

于 2012-10-12T15:10:07.300 回答