mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Fix caps and highlight embedded code-blocks
59
JUnit.md
59
JUnit.md
@@ -1,39 +1,43 @@
|
|||||||
## Getting JUnit XML from ShellCheck
|
## Getting JUnit XML from ShellCheck
|
||||||
|
|
||||||
ShellCheck does not have a JUnit XML formatter, but here you can find `checkstyle2junit.xslt`, a XSLT program that converts from Checkstyle XML output to JUnit XML.
|
ShellCheck does not have a JUnit XML formatter, but here you can find `checkstyle2junit.xslt`, an XSLT program that converts from CheckStyle's XML output to JUnit's XML.
|
||||||
|
|
||||||
Here's shellcheck's checkstyle XML output:
|
Here's ShellCheck's (CheckStyle-compatible) XML output:
|
||||||
|
|
||||||
$ shellcheck -f checkstyle foo.bash bar.bash
|
```console
|
||||||
|
$ shellcheck -f checkstyle foo.bash bar.bash
|
||||||
|
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<checkstyle version='4.3'>
|
<checkstyle version='4.3'>
|
||||||
<file name='foo.bash' >
|
<file name='foo.bash' >
|
||||||
<error line='1' column='1' severity='error' message='Tips depend on target shell and yours is unknown. Add a shebang.' source='ShellCheck.SC2148' />
|
<error line='1' column='1' severity='error' message='Tips depend on target shell and yours is unknown. Add a shebang.' source='ShellCheck.SC2148' />
|
||||||
<error line='1' column='6' severity='info' message='Double quote to prevent globbing and word splitting.' source='ShellCheck.SC2086' />
|
<error line='1' column='6' severity='info' message='Double quote to prevent globbing and word splitting.' source='ShellCheck.SC2086' />
|
||||||
</file>
|
</file>
|
||||||
<file name='bar.bash' >
|
<file name='bar.bash'>
|
||||||
</file>
|
</file>
|
||||||
</checkstyle>
|
</checkstyle>
|
||||||
|
```
|
||||||
|
|
||||||
Here it is with the XSLT applied using `xmlstarlet`:
|
Here it is with the XSLT applied using `xmlstarlet`:
|
||||||
|
|
||||||
$ shellcheck -f checkstyle foo.bash bar.bash | xmlstarlet tr checkstyle2junit.xslt
|
```console
|
||||||
|
$ shellcheck -f checkstyle foo.bash bar.bash | xmlstarlet tr checkstyle2junit.xslt
|
||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuite tests="2" failures="2">
|
<testsuite tests="2" failures="2">
|
||||||
<testcase classname="foo.bash" name="foo.bash">
|
<testcase classname="foo.bash" name="foo.bash">
|
||||||
<failure type="ShellCheck.SC2148">Line 1: Tips depend on target shell and yours is unknown. Add a shebang. See https://www.shellcheck.net/wiki/SC2148</failure>
|
<failure type="ShellCheck.SC2148">Line 1: Tips depend on target shell and yours is unknown. Add a shebang. See https://www.shellcheck.net/wiki/SC2148</failure>
|
||||||
<failure type="ShellCheck.SC2086">Line 1: Double quote to prevent globbing and word splitting. See https://www.shellcheck.net/wiki/SC2086</failure>
|
<failure type="ShellCheck.SC2086">Line 1: Double quote to prevent globbing and word splitting. See https://www.shellcheck.net/wiki/SC2086</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="bar.bash" name="bar.bash">
|
<testcase classname="bar.bash" name="bar.bash">
|
||||||
</testcase>
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
```
|
||||||
|
|
||||||
`checkstyle2junit.xslt` :
|
`checkstyle2junit.xslt`:
|
||||||
|
```xslt
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
<xsl:output encoding="UTF-8" method="xml"></xsl:output>
|
<xsl:output encoding="UTF-8" method="xml"></xsl:output>
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
@@ -75,4 +79,5 @@ Here it is with the XSLT applied using `xmlstarlet`:
|
|||||||
<xsl:value-of select="substring(@source, '12')" />
|
<xsl:value-of select="substring(@source, '12')" />
|
||||||
</failure>
|
</failure>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user