From 17e11ae624c8ca6ea13e6d9bed1d1cacfea07186 Mon Sep 17 00:00:00 2001 From: Kevin Martensson Date: Fri, 31 Oct 2014 20:19:44 +0100 Subject: [PATCH] Move coverage script to Makefile Also includes some cleanup of unnecessary files in .gitignore which should belong in a global .gitignore. --- .editorconfig | 3 +++ .gitignore | 29 +++++------------------------ Makefile | 23 +++++++++++++++++++++++ package.json | 2 +- scripts/coverage | 26 -------------------------- test/api.js | 2 +- 6 files changed, 33 insertions(+), 52 deletions(-) create mode 100644 Makefile delete mode 100644 scripts/coverage diff --git a/.editorconfig b/.editorconfig index 2d0fbc0d8..837a1f80c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index ad7b8a987..9ee4b6601 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,8 @@ -lib-cov -*.seed *.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results - -node_modules -npm-debug.log - -build -vagrant -.lock-wscript .DS_Store .sass-cache - -bin/*-v8-* - -lib-coverage/ -sass-coverage.js -**/fixtures/**/build.* +bin +!bin/node-sass +build +lib-cov +node_modules diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..1168873b8 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +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 e38bbb443..8657354fa 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "gypfile": true, "scripts": { - "coverage": "node scripts/coverage", + "coverage": "make test-cov", "install": "node lib/build.js", "prepublish": "node scripts/prepublish", "pretest": "node_modules/.bin/jshint bin lib test", diff --git a/scripts/coverage b/scripts/coverage deleted file mode 100644 index 51644e3bf..000000000 --- a/scripts/coverage +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env node -/*jshint shelljs:true */ - -"use strict"; - -require("shelljs/make"); -var path = require("path"); - -var JSCOVERAGE_BIN = ["node_modules", ".bin", "jscoverage"].join(path.sep); -var COVERALLS_BIN = ["node_modules", ".bin", "coveralls"].join(path.sep); -var MOCHA_BIN = ["node_modules", ".bin", "mocha"].join(path.sep); - -echo("Creating coverage files"); -exec(JSCOVERAGE_BIN + " lib lib-coverage"); - -echo("Piping mocha to coveralls"); - -env["NODESASS_COVERAGE"] = 1; - -exec(MOCHA_BIN + " test -R mocha-lcov-reporter | " + COVERALLS_BIN, {async: false}, function(code, output) { - console.log('Exit code:', code); - console.log('Program output:', output); - - echo("Cleanup coverage files"); - rm("-R", "lib-coverage"); -}); diff --git a/test/api.js b/test/api.js index 6eabb56fa..73b735e51 100644 --- a/test/api.js +++ b/test/api.js @@ -2,7 +2,7 @@ var assert = require('assert'), fs = require('fs'), path = require('path'), read = fs.readFileSync, - sass = require('../lib'), + sass = process.env.NODESASS_COV ? require('../lib-cov') : require('../lib'), fixture = path.join.bind(null, __dirname, 'fixtures'), resolveFixture = path.resolve.bind(null, __dirname, 'fixtures');