forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5feb745
commit 45063ae
Showing
2 changed files
with
67 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
"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); | ||
|
||
if (error) { | ||
grunt.fatal(error); | ||
} | ||
|
||
Object.keys(results) | ||
.sort(function(a, b){ | ||
if (results[a].length > results[b].length) return -1; | ||
if (results[a].length < results[b].length) return 1; | ||
return 0; | ||
}) | ||
.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); | ||
.sort(function(a, b){ | ||
if (results[a].length > results[b].length) { | ||
return -1; | ||
} | ||
if (results[a].length < results[b].length) { | ||
return 1; | ||
} | ||
return 0; | ||
}) | ||
.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( | ||
// 'https://github.com/' + process.env.TRAVIS_REPO_SLUG + '/blob/' + process.env.TRAVIS_BRANCH + relativePath + '#L' + (c.lineNum+1) + '-L' + (c.lineNum+1 + c.code.split('\n').length) | ||
// ); | ||
console.log( | ||
'txmt://open?url=' + encodeURIComponent('file://' + path) + '&line=' + (c.lineNum+1) + '&column=' + (c.column[0]+2) | ||
); | ||
// console.log(c.code.split('\n').map(function(line){return '\t' + line}).join('\n')) | ||
}); | ||
console.log(''); | ||
}); | ||
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)); | ||
}); | ||
console.log(''); | ||
}) | ||
; | ||
|
||
Object.keys(results).sort().forEach(function(path){ | ||
if (results[path].length > 0) return; | ||
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'); | ||
if (uncoveredExpressionCount > 0) { | ||
grunt.log.error(uncoveredExpressionCount + ' expressions not covered'); | ||
} | ||
if (uncoveredLineCount > 0) { | ||
grunt.log.error(uncoveredLineCount + ' lines not covered'); | ||
} | ||
done(); | ||
})); | ||
} | ||
}; |