From ce0d3251058a52bd0388e04b05cb61900b796915 Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Sun, 13 Dec 2015 23:37:23 -0600 Subject: [PATCH 1/7] Add Code Coverage configuration Fixes #33. Attempts to use blanket + mocha to generate the necessary coverage information for Coveralls. --- Gruntfile.js | 5 ++++- package.json | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 30deb8a..663e863 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,7 +7,10 @@ module.exports = function (grunt) { test: { options: { reporter: 'spec', - require: 'coffee-script' + require: [ + 'coffee-script', + 'blanket', + ] }, src: ['test/**/*.coffee'] } diff --git a/package.json b/package.json index 0266ccd..818f541 100644 --- a/package.json +++ b/package.json @@ -13,15 +13,17 @@ "url": "https://github.com/stephenyeargin/hubot-grafana/issues" }, "dependencies": { + "blanket": "^1.2.1", "knox": "^0.9.2", - "request": "^2.58.0" + "request": "^2.58.0", + "travis-cov": "^0.2.5" }, "peerDependencies": { "hubot": "2.x" }, "devDependencies": { "chai": "^2.1.1", - "coffee-script": "1.6.3", + "coffee-script": "1.10.0", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "grunt-contrib-watch": "~0.6.1", @@ -35,6 +37,18 @@ "sinon": "^1.13.0", "sinon-chai": "^2.7.0" }, + "config": { + "blanket": { + "pattern": [ + "/src/" + ], + "data-cover-never": [ + "node_modules", + "tests" + ], + "loader": "./node-loaders/coffee-script" + } + }, "main": "index.coffee", "scripts": { "test": "grunt test" From e19c70b1af5b1173067814ce7e29ccc593b5c943 Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Sun, 13 Dec 2015 23:59:44 -0600 Subject: [PATCH 2/7] Add necessary node modules. --- Gruntfile.js | 3 ++- package.json | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 663e863..28dcf9a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,7 +10,8 @@ module.exports = function (grunt) { require: [ 'coffee-script', 'blanket', - ] + ], + compilers: 'coffee:coffee-script/register' }, src: ['test/**/*.coffee'] } diff --git a/package.json b/package.json index 818f541..f8026e1 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "devDependencies": { "chai": "^2.1.1", "coffee-script": "1.10.0", + "coveralls": "^2.11.6", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "grunt-contrib-watch": "~0.6.1", @@ -33,6 +34,7 @@ "hubot-test-helper": "0.0.6", "matchdep": "~0.3.0", "mocha": "^2.1.0", + "mocha-lcov-reporter": "^1.0.0", "nock": "^2.3.0", "sinon": "^1.13.0", "sinon-chai": "^2.7.0" From d4a2a83612b88a54242ad2e4f3eae14d6162921d Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Mon, 14 Dec 2015 00:01:08 -0600 Subject: [PATCH 3/7] Move those into the dev dependencies. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f8026e1..c917266 100644 --- a/package.json +++ b/package.json @@ -13,15 +13,14 @@ "url": "https://github.com/stephenyeargin/hubot-grafana/issues" }, "dependencies": { - "blanket": "^1.2.1", "knox": "^0.9.2", "request": "^2.58.0", - "travis-cov": "^0.2.5" }, "peerDependencies": { "hubot": "2.x" }, "devDependencies": { + "blanket": "^1.2.1", "chai": "^2.1.1", "coffee-script": "1.10.0", "coveralls": "^2.11.6", @@ -37,7 +36,8 @@ "mocha-lcov-reporter": "^1.0.0", "nock": "^2.3.0", "sinon": "^1.13.0", - "sinon-chai": "^2.7.0" + "sinon-chai": "^2.7.0", + "travis-cov": "^0.2.5" }, "config": { "blanket": { From 57b70dcd48b4a2cf2024bea2eb772550b8bd6438 Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Mon, 14 Dec 2015 00:05:03 -0600 Subject: [PATCH 4/7] trailing comma --- .gitignore | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 56f99ba..c5b1172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +npm-debug.log /node_modules .node-version .idea diff --git a/package.json b/package.json index c917266..2686eec 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "knox": "^0.9.2", - "request": "^2.58.0", + "request": "^2.58.0" }, "peerDependencies": { "hubot": "2.x" From 8018d4a796bf1e3bb557b13601b2f1e79236c6da Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Mon, 14 Dec 2015 00:10:42 -0600 Subject: [PATCH 5/7] Update to match travis-cov --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 2686eec..a94f264 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,14 @@ }, "config": { "blanket": { - "pattern": [ - "/src/" - ], - "data-cover-never": [ - "node_modules", - "tests" - ], - "loader": "./node-loaders/coffee-script" + "pattern": "test", + "data-cover-flags": { + "debug": false + }, + "loader": "./node-loaders/coffee-script", + "data-cover-reporter-options": { + "shortnames": true + } } }, "main": "index.coffee", From 83094e23dcf1c16cb4acd0870124c1686e0a72cd Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Mon, 14 Dec 2015 14:59:01 -0600 Subject: [PATCH 6/7] More work with mocha --- .gitignore | 45 ++++++++++++++++++++++++++++++++++--- package.json | 1 + test/grafana-s3-test.coffee | 6 +++++ test/grafana-test.coffee | 6 +++++ test/mocha.opts | 6 +++++ test/test_helper.coffee | 2 ++ 6 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 test/mocha.opts create mode 100644 test/test_helper.coffee diff --git a/.gitignore b/.gitignore index c5b1172..504db35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,43 @@ -npm-debug.log -/node_modules -.node-version +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# IDE .idea + +# Code coverage +coverage.json + +# Node versions (nodenv) +.node-version diff --git a/package.json b/package.json index a94f264..400f847 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "mocha": "^2.1.0", "mocha-lcov-reporter": "^1.0.0", "nock": "^2.3.0", + "require-dir": "^0.3.0", "sinon": "^1.13.0", "sinon-chai": "^2.7.0", "travis-cov": "^0.2.5" diff --git a/test/grafana-s3-test.coffee b/test/grafana-s3-test.coffee index d015259..9b27a7f 100644 --- a/test/grafana-s3-test.coffee +++ b/test/grafana-s3-test.coffee @@ -10,6 +10,12 @@ expect = chai.expect room = null +before -> + matchesBlanket = (path) -> path.match /node_modules\/blanket/ + runningTestCoverage = Object.keys(require.cache).filter(matchesBlanket).length > 0 + if runningTestCoverage + require('require-dir')("#{__dirname}/../src", {recurse: true, duplicates: true}) + setupRoomAndRequestGraph = (done) -> room = helper.createRoom() diff --git a/test/grafana-test.coffee b/test/grafana-test.coffee index 5f763a7..44cc1de 100644 --- a/test/grafana-test.coffee +++ b/test/grafana-test.coffee @@ -8,6 +8,12 @@ helper = new Helper('./../src/grafana.coffee') expect = chai.expect +before -> + matchesBlanket = (path) -> path.match /node_modules\/blanket/ + runningTestCoverage = Object.keys(require.cache).filter(matchesBlanket).length > 0 + if runningTestCoverage + require('require-dir')("#{__dirname}/../src", {recurse: true, duplicates: true}) + describe 'grafana', -> room = null diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..1785b8e --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,6 @@ +--compilers coffee:coffee-script/register +--reporter list +--require coffee-script +--require test/test_helper.coffee +--colors +--full-trace diff --git a/test/test_helper.coffee b/test/test_helper.coffee new file mode 100644 index 0000000..bd01aff --- /dev/null +++ b/test/test_helper.coffee @@ -0,0 +1,2 @@ +process.env.NODE_ENV = 'test' +process.env.HUBOT_DEPLOY_APPS_JSON = require("path").join(__dirname, "test_apps.json") From 97b30c9123edd70c5dc199314239a6a5b4d3bb15 Mon Sep 17 00:00:00 2001 From: Stephen Yeargin Date: Tue, 15 Dec 2015 01:02:10 -0600 Subject: [PATCH 7/7] Update config. --- .gitignore | 1 + package.json | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 504db35..7995710 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ node_modules # Code coverage coverage.json +.coveralls.yml # Node versions (nodenv) .node-version diff --git a/package.json b/package.json index 400f847..3602fe1 100644 --- a/package.json +++ b/package.json @@ -42,14 +42,9 @@ }, "config": { "blanket": { - "pattern": "test", - "data-cover-flags": { - "debug": false - }, - "loader": "./node-loaders/coffee-script", - "data-cover-reporter-options": { - "shortnames": true - } + "pattern": "src", + "data-cover-never": "node_modules", + "loader": "./node-loaders/coffee-script" } }, "main": "index.coffee",