Commit d9a643ba by Kevin Martensson

Run coverage programmatically

parent 8ac7c037
......@@ -10,6 +10,3 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
BIN = ./node_modules/.bin
REPORTER = spec
clean:
@rm -rf lib-cov test/fixtures/*/build.css
lint:
@$(BIN)/jshint bin lib test
node_modules: package.json
@npm install
@touch node_modules
test: clean lint node_modules
@$(BIN)/_mocha \
--reporter $(REPORTER)
test-cov: clean lint node_modules
@$(BIN)/jscoverage lib lib-cov
@NODESASS_COV=1 $(BIN)/_mocha \
--reporter mocha-lcov-reporter | $(BIN)/coveralls
.PHONY: test clean
......@@ -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",
......@@ -29,6 +29,7 @@
"bin",
"binding.gyp",
"lib",
"scripts",
"src",
"test"
],
......
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();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment