这是捕获的命令和标准输出:
$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.
答案 0 :(得分:3)
这是插件中的一个错误。它查找* .tap,即使您指定了不同的文件扩展名(插件开发人员在编写该代码时可能已经喝醉了)。我填写了an issue for this,但您可以在TAP插件的当前版本(1.6)中使用您的结果执行以下操作:
1)如您所述,删除TAP计划中的空格(即:1..12而不是1 .. 12)。,
2)使用perlcritic_tap.tap而不是写perlcritic_tap.results。
我正在为此准备补丁,并将在几个小时内完成发布。更新站点在Jenkins中同步需要一段时间,但希望在周一开始工作时,您应该可以毫无问题地使用该插件。
如果您需要任何帮助,请告诉我。我在这里很新,并且没有足够的Karma来添加更多的链接,但是我已经使用你的TAP文件附加了一些插件的屏幕截图来解决Jenkins JIRA中的问题; - )
一切顺利,-kinow
答案 1 :(得分:2)
我认为这是你计划中的额外空间。 请尝试1..12。 (......之后没有空格)
我使用了Jenkins JUnit插件:
证明--formatter = TAP :: Formatter :: JUnit
答案 2 :(得分:1)
在对Jenkins进行测试时,JUnit TAP harness取得了成功。最新版本允许您通过环境变量将测试分组到包中。
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是我实现的一个小补丁)所以如果有任何限制你应该能够纠正它们。