Skip to content

Commit

Permalink
Run coverage programmatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kevva committed Nov 4, 2014
1 parent 8ac7c03 commit d9a643b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"gypfile": true,
"scripts": {
"coverage": "make test-cov",
"coverage": "node scripts/coverage.js",
"install": "node lib/build.js",
"prepublish": "node scripts/prepublish",
"pretest": "node_modules/.bin/jshint bin lib test",
Expand All @@ -29,6 +29,7 @@
"bin",
"binding.gyp",
"lib",
"scripts",
"src",
"test"
],
Expand Down
60 changes: 60 additions & 0 deletions scripts/coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
var path = require('path'),
spawn = require('child_process').spawn,
bin = path.join.bind(null, __dirname, '..', 'node_modules', '.bin');

/**
* Run test suite
*
* @api private
*/

function suite() {
process.env.NODESASS_COV = 1;

var coveralls = spawn(bin('coveralls'));
var mocha = spawn(bin('_mocha'), ['--reporter', 'mocha-lcov-reporter'], {
env: process.env
});

mocha.on('error', function(err) {
console.error(err);
process.exit(1);
});

mocha.stderr.setEncoding('utf8');
mocha.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});

mocha.stdout.pipe(coveralls.stdin);
}

/**
* Generate coverage files
*
* @api private
*/

function coverage() {
var jscoverage = spawn(bin('jscoverage'), ['lib', 'lib-cov']);

jscoverage.on('error', function(err) {
console.error(err);
process.exit(1);
});

jscoverage.stderr.setEncoding('utf8');
jscoverage.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});

jscoverage.on('close', suite);
}

/**
* Run
*/

coverage();

0 comments on commit d9a643b

Please sign in to comment.