Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix JUnit report format for thrown error (non SyntaxError).

Thrown error should also be formatted as testsuite>testcase>error,
just like a SyntaxError, so that tools like Jenkins JUnit report
visualisation includes the thrown error.

There is no parsing performance impact since this only affects
esvalidate error thrown per file.

http://code.google.com/p/esprima/issues/detail?id=374
  • Loading branch information...
commit 9300783f761757ee7d7554bf0503c446cfa9af90 1 parent dc61d53
@cliffano cliffano authored committed
Showing with 12 additions and 1 deletion.
  1. +12 −1 bin/esvalidate.js
View
13 bin/esvalidate.js 100644 → 100755
@@ -153,7 +153,18 @@ fnames.forEach(function (fname) {
}
} catch (e) {
++count;
- console.log('Error: ' + e.message);
+ if (options.format === 'junit') {
+ console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
+ ' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
+ console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
+ console.log(' <error type="ParseError" message="' + e.message + '">' +
+ e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
+ ')</error>');
+ console.log(' </testcase>');
+ console.log('</testsuite>');
+ } else {
+ console.log('Error: ' + e.message);
+ }
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.