Skip to content

Commit

Permalink
Move coverage report aggregation out into npm scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Jan 17, 2017
1 parent dec1cc5 commit 532c0b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ ESLINT := "node_modules/.bin/eslint"
KARMA := "node_modules/.bin/karma"
MOCHA := "bin/mocha"
NYC := "node_modules/.bin/nyc"
ISTANBUL_COMBINE := "node_modules/.bin/istanbul-combine"
COVERAGE_DIR := "coverage/"

ifdef COVERAGE
define test_node
$(NYC) --report-dir coverage/$(1) --reporter json --exclude browser $(MOCHA)
$(NYC) --report-dir coverage/reports/$(1) --reporter json --exclude browser $(MOCHA)
endef
else
test_node := $(MOCHA)
endif

TM_BUNDLE = JavaScript\ mocha.tmbundle
SRC = $(shell find lib -name "*.js" -type f | sort)
Expand All @@ -33,17 +35,11 @@ lint:
@printf "==> [Test :: Lint]\n"
$(ESLINT) . bin/*

COVERAGE_TMP_DIR:=$(shell mktemp -d)
generate-coverage-report:
$(ISTANBUL_COMBINE) -d $(COVERAGE_TMP_DIR) -r lcov -r html $(COVERAGE_DIR)/*/*.json
rm -rf $(COVERAGE_DIR)
mv $(COVERAGE_TMP_DIR) $(COVERAGE_DIR)

test-node: test-bdd test-tdd test-qunit test-exports test-unit test-integration test-jsapi test-compilers test-glob test-requires test-reporters test-only test-global-only

test-browser: clean mocha.js test-browser-unit test-browser-bdd test-browser-qunit test-browser-tdd test-browser-exports

test: lint test-node test-browser generate-coverage-report
test: lint test-node test-browser

test-browser-unit:
@printf "==> [Test :: Browser]\n"
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@
"npm": ">= 1.4.x"
},
"scripts": {
"test": "make test"
"test": "make test",
"precoverage": "rm -rf coverage",
"coverage": "COVERAGE=true npm run test",
"postcoverage": "istanbul-combine -d coverage -r lcov -r html coverage/reports/*/*.json"
},
"dependencies": {
"browser-stdout": "1.3.0",
Expand Down

0 comments on commit 532c0b8

Please sign in to comment.