2012-10-12 27 views
1

詹金斯顯示TAP輸出這裏是拍攝的命令和stdout:如何從perlcritic

$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) 

,但我仍然不能得到詹金斯承認TAP文件格式,我得到一個錯誤:

Found matching files but did not find any TAP results. 
+1

您是否嘗試過'Test :: Perl :: Critic'? – RobEarl

+0

您是否嘗試刪除部分輸出行以確定是否有任何字符(例如。:()「)正在進行中? –

+0

優秀的建議,我會嘗試兩個 – kamal

回答

3

它是在插件中的錯誤在。即使您指定了不同的文件擴展名(插件開發人員在編寫代碼時可能已經醉了),它也會查找* .tap。我填充了an issue for this,但是您可以在當前版本(1.6)的TAP插件中執行以下操作:

1)如您所述,刪除TAP計劃中的空間(即:1 ..12而不是1 .. 12),

2)而不是寫percerritic_tap.results,使用perlcritic_tap.tap。

我正在爲此準備一個補丁,並會在幾個小時內發佈一個版本。更新站點在Jenkins中同步需要一段時間,但希望在週一工作之前,您應該可以毫無問題地使用該插件。

讓我知道你是否需要任何東西。我在這裏很新,沒有足夠的Karma來添加更多鏈接,但我已經使用TAP文件附加了一些屏幕截圖,用於Jenkins JIRA中的問題;-)

全部最好的, - 皮膚

+1

perlcritic --gentle cgi-bin/cr/| tee pc.out工作,再加上我使用Jenkins的Violations插件 – kamal

1

我已經與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是一個小補丁,我實現),所以如果有任何限制,你應該能夠改正。

+0

因此,您使用Perl :: Critic與TAP :: Harness :: JUnit來獲取XML輸出?因爲我沒有單元測試,所以我只想運行Perl :: Critic對Perl代碼 – kamal

+0

不,只是使用標準測試,但它似乎將TAP轉換爲JUnit就好了,並且對測試進行分組。 –

1

我認爲這是您計劃中的額外空間。 請嘗試1..12。我已經使用了JUnit的詹金斯與插件(後沒有空格的..)

證明--formatter = TAP ::格式化:: JUnit的

+0

我意識到了錯誤並糾正了錯誤,但這並沒有解決問題。 Good Catch BTW – kamal