Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(tests): switch coverage tool, add coveralls (#145) r=vbudhram
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikoff committed Jul 20, 2016
1 parent bae1957 commit 617bab8
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 250 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@ fxa-auth-db-server/node_modules
node_modules/
sandbox/
coverage.html
.nyc_output
*.log
*.swp
*~
5 changes: 4 additions & 1 deletion .travis.yml
Expand Up @@ -40,7 +40,10 @@ before_script:
- grunt nsp --force

script:
- npm test
# 'npm run test-travis' runs all tests together to collect all coverage into one from mysql and db-server
- COVERALLS_REPO_TOKEN=mlOESL8slkePkodJpcvhF1AUKUH3llXi8 npm run test-travis
# memory tests are separate to avoid being included into coverage because they run through the same code
- npm run test-mem

matrix:
allow_failures:
Expand Down
5 changes: 0 additions & 5 deletions bin/mem.js
Expand Up @@ -12,11 +12,6 @@ function shutdown() {
process.nextTick(process.exit)
}

// defer to allow ass code coverage results to complete processing
if (process.env.ASS_CODE_COVERAGE) {
process.on('SIGINT', shutdown)
}

DB.connect(config)
.done(function (db) {
var server = dbServer.createServer(db)
Expand Down
5 changes: 0 additions & 5 deletions bin/server.js
Expand Up @@ -13,11 +13,6 @@ function shutdown() {
process.nextTick(process.exit)
}

// defer to allow ass code coverage results to complete processing
if (process.env.ASS_CODE_COVERAGE) {
process.on('SIGINT', shutdown)
}

function logCharsetInfo(db, poolName) {
// Record some information about mysql connection configuration and
// charset at startup.
Expand Down
1 change: 0 additions & 1 deletion fxa-auth-db-server/test/local/bufferize.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var test = require('tap').test
var sinon = require('sinon')

Expand Down
1 change: 0 additions & 1 deletion fxa-auth-db-server/test/local/error.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var test = require('tap').test

test(
Expand Down
162 changes: 0 additions & 162 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -18,7 +18,8 @@
"test": "npm run test-mysql && npm run test-mem && npm run test-server",
"test-mem": "./scripts/tap-coverage.js test/mem",
"test-mysql": "grunt && node ./bin/db_patcher.js >/dev/null && ./scripts/tap-coverage.js test/backend test/local",
"test-server": "./scripts/tap-coverage.js fxa-auth-db-server/test/local"
"test-server": "./scripts/tap-coverage.js fxa-auth-db-server/test/local",
"test-travis": "grunt && node ./bin/db_patcher.js >/dev/null && ./scripts/tap-coverage.js test/backend test/local fxa-auth-db-server/test/local"
},
"author": "Mozilla (https://mozilla.org/)",
"homepage": "https://github.com/mozilla/fxa-auth-db-mysql",
Expand All @@ -38,7 +39,6 @@
"restify": "4.1.1"
},
"devDependencies": {
"ass": "git://github.com/jrgm/ass.git#5be99ee",
"eslint-config-fxa": "2.1.0",
"grunt": "1.0.1",
"grunt-bump": "0.8.0",
Expand Down
41 changes: 12 additions & 29 deletions scripts/tap-coverage.js
@@ -1,38 +1,21 @@
#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

if (!process.env.NO_COVERAGE) {
var ass = require('ass').enable( {
// exclude files in /client/ and /test/ from code coverage
exclude: [ '/client/', '/test', '/fxa-auth-db-server/node_modules/' ]
})
}
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var path = require('path'),
spawn = require('child_process').spawn,
fs = require('fs')
spawn = require('child_process').spawn

var COVERAGE_ARGS = ['--coverage', '--cov']
if (process.env.NO_COVERAGE) {
COVERAGE_ARGS = []
}

var p = spawn(path.join(path.dirname(__dirname), 'node_modules', '.bin', 'tap'),
process.argv.slice(2), { stdio: 'inherit' })
process.argv.slice(2).concat(COVERAGE_ARGS), { stdio: 'inherit', env: process.env })

p.on('close', function(code) {
if (!process.env.NO_COVERAGE) {
ass.report('json', function(err, r) {
console.log('code coverage:', r.percent + '%') //eslint-disable-line no-console
process.stdout.write('generating coverage.html: ')
var start = new Date()
ass.report('html', function(err, html) {
fs.writeFileSync(path.join(path.dirname(__dirname), 'coverage.html'),
html)
process.stdout.write('complete in ' +
((new Date() - start) / 1000.0).toFixed(1) + 's\n')
process.exit(code)
})
})
} else {
process.exit(code)
}
// exit this process with the same exit code as the test process
p.on('close', function (code) {
process.exit(code)
})
1 change: 0 additions & 1 deletion test/backend/db_tests.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var dbServer = require('../../fxa-auth-db-server')
var dbTests = require('../../fxa-auth-db-server/test/backend').dbTests
var log = require('../lib/log')
Expand Down
9 changes: 0 additions & 9 deletions test/backend/remote.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var dbServer = require('../../fxa-auth-db-server')
var backendTests = require('../../fxa-auth-db-server/test/backend')
var config = require('../../config')
Expand All @@ -10,14 +9,6 @@ var DB = require('../../lib/db/mysql')(log, dbServer.errors)
var P = require('bluebird')

var server

// defer to allow ass code coverage results to complete processing
if (process.env.ASS_CODE_COVERAGE) {
process.on('SIGINT', function() {
process.nextTick(process.exit)
})
}

var db

DB.connect(config)
Expand Down
1 change: 0 additions & 1 deletion test/db_server_stub.js
Expand Up @@ -2,5 +2,4 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

require('ass')
require('../bin/server')
1 change: 0 additions & 1 deletion test/local/event_log.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var dbServer = require('../../fxa-auth-db-server')
var test = require('tap').test
var log = require('../lib/log')
Expand Down
1 change: 0 additions & 1 deletion test/local/incorrect-patch-level.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var dbServer = require('../../fxa-auth-db-server')
var log = require('../lib/log')
var DB = require('../../lib/db/mysql')(log, dbServer.errors)
Expand Down
1 change: 0 additions & 1 deletion test/local/log-stats.js
@@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

require('ass')
var dbServer = require('../../fxa-auth-db-server')
var test = require('tap').test
var P = require('../../lib/promise')
Expand Down

0 comments on commit 617bab8

Please sign in to comment.