Search code examples
perljenkinstap

How to get Jenkins display TAP output from perlcritic


Here is the command and stdout captured:

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

output:

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)

Verify the file contents:

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)

Now append the top portion of TAP format:

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)

But i still cannot get Jenkins to recognize the TAP file format, and i get an error:

Found matching files but did not find any TAP results.

Solution

  • It is a bug in the plug-in. It looks for *.tap, even though you specified a different file extension (the plug-in developer probably was drunk when he wrote that code). I've filled an issue for this, but you can have your results working in the current version (1.6) of TAP plug-in doing the following:

    1) as you mentioned, remove the space in the TAP plan (i.e.: 1..12 rather than 1.. 12).,

    2) instead of writing perlcritic_tap.results, use perlcritic_tap.tap.

    I'm preparing a patch for this and will cut a release in few hours. It takes a while before the update site is synced in Jenkins, but hopefully by Monday at work you should be able to use the plug-in with no problem.

    Let me know if you need anything. I'm quite new here, and don't have Karma enough to add more links, but I've attached some screen shots of the plug-in using your TAP file to the issue in Jenkins JIRA ;-)

    All the best, -kinow