Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jUnit Support #27

Merged
merged 2 commits into from Jul 25, 2013
Merged

jUnit Support #27

merged 2 commits into from Jul 25, 2013

Conversation

xjamundx
Copy link
Contributor

The output looks nice when there are errors, but may be problems when there are not any errors.

I'm not a jUnit expert, so mainly I wanted to some feedback to make sure I was close :)

This will hopefully solve issue #16.

~/dev/eslint [master] $ node ./bin/eslint.js ./lib/options.js -f junit
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testcase package="eslint" time="0" tests="15" errors="15" name="./lib/options.js">
<error message="Missing semicolon."><![CDATA[line 12, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 18, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 21, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 22, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 23, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 26, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 27, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 30, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 33, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 34, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 35, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 41, col 0, Warning - Missing semicolon.]]></error>
<error message="Missing semicolon."><![CDATA[line 42, col 4, Warning - Missing semicolon.]]></error>
<error message="Unexpected console statement."><![CDATA[line 42, col 4, Warning - Unexpected console statement.]]></error>
<error message="Missing semicolon."><![CDATA[line 45, col 0, Warning - Missing semicolon.]]></error>
</testsuites>

@nzakas
Copy link
Member

nzakas commented Jul 14, 2013

Not a bad first attempt. The hierarchy is testsuites -> testsuite -> testcase -> error. Take a look at how we did it for CSS Lint.

Source: https://github.com/stubbornella/csslint/blob/master/src/formatters/junit-xml.js

Tests: https://github.com/stubbornella/csslint/blob/master/tests/formatters/junit-xml.js

You may event want to try running CSS Lint on a CSS file and specify JUnit XML as the output format to get a good example.

@xjamundx
Copy link
Contributor Author

Thanks for the feedback! I knew I was missing something. I'll get those fixes in ASAP!

@xjamundx
Copy link
Contributor Author

Okay I updated most of that stuff.

What are we going to do about support & testing the output for multiple files?

Currently the formatters only seem to support 1 file at a time for structured output like this. Obviously this can be solved by adding awk or whatever to the build step before this gets ingested, but probably we should update the formatter to do one of 2 things:

  1. Optionally specify startText and endText parameters: https://github.com/stubbornella/csslint/blob/master/src/formatters/junit-xml.js
  2. Send the formatter the result from all of the files:
    https://github.com/jshint/jshint/blob/master/src/reporters/jslint_xml.js

Here's an example of the latest using my pull request:

$ node ./bin/eslint.js -f junit lib

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite package="org.eslint" time="0" tests="14" errors="14" name="lib/rules/no-unreachable.js">
<testcase time="0" name="org.eslint.semi"><failure message="Missing semicolon."><![CDATA[line 18, col 0, Warning - Missing semicolon.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-unreachable"><failure message="Found unexpected statement after a false."><![CDATA[line 34, col 4, Warning - Found unexpected statement after a false.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 21, col 13, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 22, col 19, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 23, col 13, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 24, col 19, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 25, col 13, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 26, col 19, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 27, col 13, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 28, col 19, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 35, col 8, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-unreachable"><failure message="Found unexpected statement after a false."><![CDATA[line 37, col 12, Warning - Found unexpected statement after a false.]]></failure></testcase>
<testcase time="0" name="org.eslint.semi"><failure message="Missing semicolon."><![CDATA[line 36, col 12, Warning - Missing semicolon.]]></failure></testcase>
<testcase time="0" name="org.eslint.unknown"><error message="Cannot read property &apos;name&apos; of null"><![CDATA[line undefined, col undefined, Error - Cannot read property &apos;name&apos; of null]]></error></testcase>
</testsuite>
</testsuites>

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite package="org.eslint" time="0" tests="3" errors="3" name="lib/rules/no-with.js">
<testcase time="0" name="org.eslint.semi"><failure message="Missing semicolon."><![CDATA[line 13, col 0, Warning - Missing semicolon.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-octal"><failure message="Octal literals should not be used."><![CDATA[line 16, col 8, Warning - Octal literals should not be used.]]></failure></testcase>
<testcase time="0" name="org.eslint.semi"><failure message="Missing semicolon."><![CDATA[line 17, col 12, Warning - Missing semicolon.]]></failure></testcase>
</testsuite>
</testsuites>

@nzakas
Copy link
Member

nzakas commented Jul 16, 2013

Very good point. To keep it simple, let's start by passing in all results.

@xjamundx
Copy link
Contributor Author

Okay I'll send a PR for it in a few days or less :)

@nzakas
Copy link
Member

nzakas commented Jul 16, 2013

Awesome, thanks!

On Tue, Jul 16, 2013 at 10:52 AM, Jamund Ferguson
notifications@github.comwrote:

Okay I'll send a PR for it in a few days or less :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/27#issuecomment-21060239
.


Nicholas C. Zakas
@SlickNet

Author, Professional JavaScript for Web Developers
Buy it at Amazon.com:
http://www.amazon.com/Professional-JavaScript-Developers-Nicholas-Zakas/dp/1118026691/ref=sr_1_3

@nzakas nzakas mentioned this pull request Jul 18, 2013
@xjamundx
Copy link
Contributor Author

Mulitple file support is in and it looks like this. Let me know if any other changes are needed.

~/dev/eslint [master] $ node ./bin/eslint.js -f junit lib
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite package="org.eslint" time="0" tests="5" errors="5" name="lib/cli.js">
<testcase time="0" name="org.eslint.camelcase"><failure message="Non-camelcased identifier &apos;__dirname&apos; found."><![CDATA[line 29, col 38, Warning - Non-camelcased identifier &apos;__dirname&apos; found.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 82, col 8, Warning - Unexpected console statement.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 85, col 4, Warning - Unexpected console statement.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 107, col 8, Warning - Unexpected console statement.]]></failure></testcase>
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 178, col 12, Warning - Unexpected console statement.]]></failure></testcase>
</testsuite>
<testsuite package="org.eslint" time="0" tests="1" errors="1" name="lib/formatters/junit.js">
<testcase time="0" name="org.eslint.semi"><failure message="Missing semicolon."><![CDATA[line 46, col 9, Warning - Missing semicolon.]]></failure></testcase>
</testsuite>
<testsuite package="org.eslint" time="0" tests="1" errors="1" name="lib/options.js">
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 44, col 4, Warning - Unexpected console statement.]]></failure></testcase>
</testsuite>
<testsuite package="org.eslint" time="0" tests="2" errors="2" name="lib/rules.js">
<testcase time="0" name="org.eslint.no-console"><failure message="Unexpected console statement."><![CDATA[line 43, col 8, Warning - Unexpected console statement.]]></failure></testcase>
<testcase time="0" name="org.eslint.camelcase"><failure message="Non-camelcased identifier &apos;__dirname&apos; found."><![CDATA[line 58, col 23, Warning - Non-camelcased identifier &apos;__dirname&apos; found.]]></failure></testcase>
</testsuite>
</testsuites>

@nzakas
Copy link
Member

nzakas commented Jul 21, 2013

Looks to good to me! Can you update this PR with the latest?

nzakas added a commit that referenced this pull request Jul 25, 2013
@nzakas nzakas merged commit 5017e65 into eslint:master Jul 25, 2013
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants