From d9a643ba7f666a4da083dc8b24f18710883883b6 Mon Sep 17 00:00:00 2001 From: Kevin Martensson Date: Tue, 4 Nov 2014 12:27:26 +0100 Subject: [PATCH] Run coverage programmatically --- .editorconfig | 3 --- Makefile | 23 ----------------- package.json | 3 ++- scripts/coverage.js | 60 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 27 deletions(-) delete mode 100644 Makefile create mode 100644 scripts/coverage.js diff --git a/.editorconfig b/.editorconfig index 837a1f80c..2d0fbc0d8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,3 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 2 - -[Makefile] -indent_style = tab diff --git a/Makefile b/Makefile deleted file mode 100644 index 1168873b8..000000000 --- a/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -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 diff --git a/package.json b/package.json index 8657354fa..643ca8d43 100644 --- a/package.json +++ b/package.json @@ -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" ], diff --git a/scripts/coverage.js b/scripts/coverage.js new file mode 100644 index 000000000..e54f0748e --- /dev/null +++ b/scripts/coverage.js @@ -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();