Skip to content

Commit

Permalink
build: use nyc for coverage testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jul 11, 2020
1 parent deef329 commit 73364d0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.nyc_output
coverage
node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.nyc_output/
coverage/
node_modules/
npm-debug.log
Expand Down
27 changes: 18 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ before_install:
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
npm install --save-dev mocha@7.2.0
fi
- |
# istanbul for coverage
# - remove for Node.js < 0.10
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
npm rm --silent --save-dev istanbul
fi
- |
# browserify for browser testing
# - install for Node.js > 0.8
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -gt 0 || "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -gt 8 ]]; then
npm install --silent --save-dev browserify
fi
- |
# nyc for coverage
# - remove for Node.js < 0.10
# - use 10.x for Node.js < 4
# - use 11.x for Node.js < 6
# - use 14.x for Node.js < 8
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
npm rm --save-dev nyc
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then
npm install --save-dev nyc@10.3.2
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
npm install --save-dev nyc@11.9.0
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 8 ]]; then
npm install --save-dev nyc@14.1.1
fi
- |
# eslint for linting
# - remove on Node.js < 8
Expand All @@ -79,7 +88,7 @@ before_install:
script:
# Run test script
- |
if npm -ps ls istanbul | grep -q istanbul; then
if npm -ps ls nyc | grep -q nyc; then
npm run test-ci
else
npm test
Expand All @@ -92,7 +101,7 @@ script:
after_script:
- |
# Upload coverage to coveralls
if [[ -f ./coverage/lcov.info ]]; then
if [[ -d .nyc_output ]]; then
npm install --save-dev coveralls@2.10.0
coveralls < ./coverage/lcov.info
nyc report --reporter=text-lcov | coveralls
fi
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install:
# Remove benchmark dependencies
npm rm --silent --save-dev benchmark beautify-benchmark
# Remove coverage dependency
npm rm --silent --save-dev istanbul
npm rm --silent --save-dev nyc
# Remove lint dependencies
cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
sls "^eslint(-|$)" | `
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
"eslint-plugin-node": "9.2.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"istanbul": "0.4.5",
"nyc": "15.1.0",
"mocha": "8.0.1",
"safe-buffer": "5.1.2",
"uid-safe": "2.1.5"
"safe-buffer": "5.1.2"
},
"files": [
"lib/",
Expand All @@ -39,7 +38,7 @@
"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail test/",
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
"test-ci": "nyc --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}
7 changes: 1 addition & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var path = require('path')
var script = path.join(__dirname, 'fixtures', 'script.js')
var spawn = require('child_process').spawn
var strictlib = libs.strict
var uid = require('uid-safe').sync

describe('depd(namespace)', function () {
it('creates deprecated function', function () {
Expand Down Expand Up @@ -761,11 +760,7 @@ function captureChildStderr (script, opts, callback) {
var env = { PATH: process.env.PATH }
var exec = process.execPath

var args = process.env.running_under_istanbul
? opts.concat(path.join(__dirname, '..', 'node_modules', 'istanbul', 'lib', 'cli.js'),
'cover', '--dir=./coverage/child-' + uid(8), '--print=none', script)
: opts.concat(script)

var args = opts.concat(script)
var proc = spawn(exec, args, {
env: env
})
Expand Down

0 comments on commit 73364d0

Please sign in to comment.