-
Notifications
You must be signed in to change notification settings - Fork 48.7k
code coverage grunt tasks #550
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
Changes from all commits
61c1bf0
5aa9013
4c881d8
646421f
ef5a02c
cb6b7f3
b5b60a6
ad0d9e4
8f96ec2
eda56b7
5feb745
45063ae
c6f7fe0
5ae152c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ module.exports = function() { | |
}; | ||
|
||
// TODO: make sure this works, test with this too | ||
config.transforms.forEach(bundle.transform, this); | ||
config.transforms.forEach(bundle.transform, bundle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What arguments does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To answer my own question: I guess There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly |
||
|
||
// Actually bundle it up | ||
var _this = this; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"use strict"; | ||
var grunt = require('grunt'); | ||
|
||
module.exports = function(){ | ||
var ROOT = require('path').normalize(__dirname + '/../..'); | ||
var done = this.async(); | ||
var uncoveredExpressionCount = 0; | ||
var uncoveredLineCount = 0; | ||
|
||
require('fs').createReadStream(ROOT + '/coverage.log') | ||
.pipe(require('coverify/parse')(function(error, results){ | ||
if (error) { | ||
grunt.fatal(error); | ||
} | ||
|
||
Object.keys(results) | ||
.sort(function(a, b){ | ||
return results[a].length - results[b].length; | ||
}) | ||
.reverse() | ||
.forEach(function(path){ | ||
if (results[path].length === 0) { | ||
return; | ||
} | ||
var relativePath = path.replace(ROOT, ''); | ||
uncoveredExpressionCount += results[path].length; | ||
grunt.log.error(results[path].length + ' expressions not covered ' + relativePath); | ||
|
||
results[path].forEach(function(c){ | ||
uncoveredLineCount += c.code.split('\n').length; | ||
console.log('txmt://open?url=' + encodeURIComponent('file://' + path) + '&line=' + (c.lineNum+1) + '&column=' + (c.column[0]+2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: figure out how to log a similar URL for Sublime text and/or Emacs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sublime Text can be made to support |
||
}); | ||
console.log(''); | ||
}) | ||
; | ||
|
||
Object.keys(results).sort().forEach(function(path){ | ||
if (results[path].length > 0) { | ||
return; | ||
} | ||
var relativePath = path.replace(ROOT, ''); | ||
grunt.log.ok('100% coverage ' + relativePath); | ||
}); | ||
|
||
if (uncoveredExpressionCount > 0) { | ||
grunt.log.error(uncoveredExpressionCount + ' expressions not covered'); | ||
} | ||
if (uncoveredLineCount > 0) { | ||
grunt.log.error(uncoveredLineCount + ' lines not covered'); | ||
} | ||
done(); | ||
})); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
/* jshint worker: true */ | ||
"use strict"; | ||
|
||
if (typeof console == 'undefined') { | ||
this.console = { | ||
error: function(e){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make these methods take multiple arguments, like the standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YAGNI. As soon as we need that, absolutely. |
||
postMessage(JSON.stringify({ | ||
type: 'error', | ||
message: e.message, | ||
stack: e.stack | ||
})); | ||
}, | ||
log: function(message){ | ||
postMessage(JSON.stringify({ | ||
type: 'log', | ||
message: message | ||
})); | ||
} | ||
} | ||
} | ||
|
||
console.log('worker BEGIN'); | ||
|
||
// The UMD wrapper tries to store on `global` if `window` isn't available | ||
var global = {}; | ||
importScripts("phantomjs-shims.js"); | ||
|
||
try { | ||
importScripts("../../build/react.js"); | ||
} catch (e) { | ||
postMessage(JSON.stringify({ | ||
type: 'error', | ||
message: e.message, | ||
stack: e.stack | ||
})); | ||
console.error(e); | ||
} | ||
|
||
postMessage(JSON.stringify({ | ||
type: 'done' | ||
})); | ||
|
||
console.log('worker END'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
var __DEBUG__ = location.search.substring(1).indexOf('debug') != -1; | ||
|
||
if (typeof console == 'undefined') console = { | ||
log: function(){}, | ||
warn: function(){}, | ||
error: function(){} | ||
}; | ||
|
||
var __consoleReport__ = []; | ||
|
||
console._log = console.log; | ||
console.log = function(message){ | ||
console._log(message); | ||
postDataToURL({type:'log', message:message}, '/reportTestResults'); | ||
if (__DEBUG__) postDataToURL({type:'log', message:message}, '/reportTestResults'); | ||
else __consoleReport__.push({type:'log', message:message}); | ||
} | ||
|
||
console._error = console.error; | ||
console.error = function(message){ | ||
console._error(message); | ||
postDataToURL({type:'error', message:message}, '/reportTestResults'); | ||
if (__DEBUG__) postDataToURL({type:'error', message:message}, '/reportTestResults'); | ||
else __consoleReport__.push({type:'error', message:message}); | ||
} | ||
|
||
console._flush = function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh derp, nvm |
||
postDataToURL(__consoleReport__, '/console'); | ||
__consoleReport__.length = 0; | ||
} | ||
|
||
;(function(env){ | ||
env.addReporter(new jasmine.JSReporter()); | ||
if (location.search.substring(1).indexOf('debug') != -1){ | ||
env.addReporter(new TAPReporter(console.log.bind(console))); | ||
} | ||
env.addReporter(new TAPReporter(console.log.bind(console))); | ||
|
||
function report(){ | ||
if (typeof jasmine.getJSReport != 'function') { | ||
console.log("typeof jasmine.getJSReport != 'function'"); | ||
return setTimeout(report, 100); | ||
} | ||
postDataToURL(jasmine.getJSReport(), '/reportTestResults', function(error, results){ | ||
if (error) return console.error(error); | ||
}); | ||
if (!__DEBUG__) { | ||
console.log('DONE\t' + navigator.userAgent); | ||
console._flush(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I implemented it a few lines up. |
||
} | ||
} | ||
|
||
var oldCallback = env.currentRunner().finishCallback; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the style here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/me almost fails to completely suppress the desire to discuss code formatting style
You're welcome.