-
Notifications
You must be signed in to change notification settings - Fork 64
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
Showing
10 changed files
with
192 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# Generate code coverage and post it to Coveralls. | ||
set -o errexit | ||
set -x | ||
|
||
# Generate LCOV data for the bundled tests using poncho | ||
grunt coverage | ||
|
||
# Convert code coverage data on the bundled test file back to the originals. | ||
./scripts/transform-coverage.js \ | ||
build/tests.map \ | ||
build/bundled.lcov \ | ||
| ./node_modules/.bin/coveralls |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
var sourcemap = require('source-map'); | ||
var fs = require('fs'); | ||
var parseDataUri = require('parse-data-uri') | ||
var lcovParse = require('lcov-parse'); | ||
var assert = require('assert'); | ||
|
||
var sourcemapfile = process.argv[2]; | ||
var lcovfile = process.argv[3]; | ||
|
||
var sourcemap_data = fs.readFileSync(sourcemapfile).toString(); | ||
var sourcemap_consumer = new sourcemap.SourceMapConsumer(sourcemap_data); | ||
|
||
var SOURCE = 'src/'; | ||
|
||
lcovParse(lcovfile, function(err, data) { | ||
assert(!err); | ||
// TODO: 0 --> the correct file | ||
var lines = data[0].lines.details; | ||
|
||
var fileToCov = {}; // filename -> { line num -> hits } | ||
|
||
lines.forEach(function(line) { | ||
var num = line.line, hits = line.hit; | ||
var original_position = sourcemap_consumer.originalPositionFor({ line: num, column: 0 }); | ||
if (original_position == null) { | ||
return; | ||
} | ||
|
||
original_filename = original_position.source; | ||
original_num = original_position.line; | ||
|
||
if (!original_filename || original_filename.indexOf('node_modules') >= 0) { | ||
return; | ||
} | ||
|
||
var base = original_filename.indexOf(SOURCE); | ||
if (base == -1) return; | ||
original_filename = original_filename.slice(base); | ||
|
||
if (!fileToCov[original_filename]) fileToCov[original_filename] = []; | ||
fileToCov[original_filename][original_num] = hits; | ||
}); | ||
|
||
// Convert to LCOV format | ||
for (var filename in fileToCov) { | ||
var cov = fileToCov[filename] | ||
console.log('SF:' + filename); | ||
for (var i = 0; i < cov.length; i++) { | ||
if (cov[i] != null) { | ||
console.log('DA:' + i + ',' + cov[i]); | ||
} | ||
} | ||
console.log('end_of_record'); | ||
} | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>pileup.js Tests</title> | ||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" /> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
|
||
<!-- Polyfills for PhantomJS --> | ||
<script src="../node_modules/es5-shim/es5-shim.min.js"></script> | ||
<script src="../node_modules/es5-shim/es5-sham.min.js"></script> | ||
<script src="../node_modules/text-encoding/lib/encoding.js"></script> | ||
|
||
<!-- Mocha --> | ||
<script src="../node_modules/mocha/mocha.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
|
||
<!--<script src="../build/cov/tests-debug.js"></script>--> | ||
<!--<script src="../build/tests-debug.js"></script>--> | ||
<script src="../build/cov/tests.js"></script> | ||
|
||
<script> | ||
mocha.checkLeaks(); | ||
if (window.mochaPhantomJS) { | ||
mochaPhantomJS.run(); | ||
} else { | ||
mocha.run(); | ||
} | ||
</script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
/** | ||
* Expose `LCov`. | ||
*/ | ||
|
||
exports = module.exports = LCov; | ||
|
||
/** | ||
* Initialize a new LCOV reporter. | ||
* File format of LCOV can be found here: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php | ||
* The reporter is built after this parser: https://raw.github.com/SonarCommunity/sonar-javascript/master/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/coverage/LCOVParser.java | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
|
||
function LCov(runner) { | ||
runner.on('end', function(){ | ||
// In a browser context, coverage will be in window.$jscoverage. | ||
var g = typeof(global) != 'undefined' ? global : window; | ||
var cov = g._$jscoverage || {}; | ||
|
||
for (var filename in cov) { | ||
var data = cov[filename]; | ||
reportFile(filename, data); | ||
} | ||
}); | ||
} | ||
|
||
function reportFile(filename, data) { | ||
process.stdout.write('SF:' + filename + '\n'); | ||
|
||
data.source.forEach(function(line, num) { | ||
// increase the line number, as JS arrays are zero-based | ||
num++; | ||
|
||
if (data[num] !== undefined) { | ||
process.stdout.write('DA:' + num + ',' + data[num] + '\n'); | ||
} | ||
}); | ||
|
||
process.stdout.write('end_of_record\n'); | ||
} |
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