Skip to content

Commit

Permalink
Rewrite Makefile using NPS Scripts. Closes mochajs#2352
Browse files Browse the repository at this point in the history
Addresses mochajs#2352
  • Loading branch information
TedYav committed Jan 8, 2018
1 parent a723b8f commit 7c830a6
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 196 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ matrix:
fast_finish: true
include:
- node_js: '9'
env: TARGET=test-node COVERAGE=true
env: TARGET=test.node COVERAGE=true
- node_js: '8'
env: TARGET=test-node
env: TARGET=test.node
- node_js: '6'
env: TARGET=test-node
env: TARGET=test.node
- node_js: '4'
env: TARGET=test-node
env: TARGET=test.node
- node_js: '8'
env: TARGET=lint
- node_js: '8'
env: TARGET=test-browser
env: TARGET=test.browser

before_install: scripts/travis-before-install.sh

before_script: scripts/travis-before-script.sh

script: make $TARGET
script: npm start $TARGET

after_success: npm run coveralls
after_success: npm start coveralls

notifications:
email: false
Expand Down
176 changes: 0 additions & 176 deletions Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ install:
- set PHANTOMJS_CDNURL=https://cnpmjs.org/downloads
- npm install -g npm
- npm install
- copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
matrix:
fast_finish: true
build: off
Expand All @@ -23,7 +22,7 @@ clone_depth: 1
test_script:
- node --version
- npm --version
- make test-node
- npm start test.node
skip_commits:
message: /\[ci\s+skip\]/

107 changes: 107 additions & 0 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
'use strict';

const BROWSERIFY = 'node_modules/.bin/browserify';
const KARMA = 'node_modules/.bin/karma';
const MOCHA = 'bin/mocha';
const NYC = 'node_modules/.bin/nyc';
const TM_BUNDLE = 'JavaScript\\ mocha.tmbundle';

function test (testName, params) {
const prefix = process.env.COVERAGE ? `${NYC} --no-clean --report-dir coverage/reports/${testName}` : '';
return `${prefix} ${MOCHA} ${params}`;
}

module.exports = {
scripts: {
build: `${BROWSERIFY} ./browser-entry --plugin ./scripts/dedefine --ignore 'fs' --ignore 'glob' --ignore 'path' --ignore 'supports-color' > mocha.js`,
lint: {
default: 'nps lint.code lint.markdown',
code: 'eslint . bin/*',
markdown: 'markdownlint "*.md" "docs/**/*.md" ".github/*.md"'
},
clean: 'rm -f mocha.js',
test: {
default: 'nps lint.code test.node test.browser',
node: {
default: 'nps test.node.all',
all: {
script: 'nps ' +
'test.node.bdd ' +
'test.node.tdd ' +
'test.node.qunit ' +
'test.node.exports ' +
'test.node.unit ' +
'test.node.integration ' +
'test.node.jsapi ' +
'test.node.compilers ' +
'test.node.requires ' +
'test.node.reporters ' +
'test.node.only ' +
'test.node.globalOnly',
description: 'Run all tests for node environment'
},
bdd: test('bdd', '--ui bdd test/interfaces/bdd.spec'),
tdd: test('tdd', '--ui tdd test/interfaces/tdd.spec'),
qunit: test('qunit', '--ui qunit test/interfaces/qunit.spec'),
exports: test('exports', '--ui exports test/interfaces/exports.spec'),
unit: test('unit', 'test/unit/*.spec.js test/node-unit/*.spec.js --growl'),
integration: test('integration', '--timeout 5000 --slow 500 test/integration/*.spec.js'),
jsapi: 'node test/jsapi',
compilers: {
default: 'nps test.node.compilers.coffee test.node.compilers.custom test.node.compilers.multiple',
coffee: test('compilers-coffee', '--compilers coffee:coffee-script/register test/compiler'),
custom: test('compilers-custom', '--compilers foo:./test/compiler-fixtures/foo.fixture test/compiler'),
multiple: test('compilers-multiple', '--compilers coffee:coffee-script/register,foo:./test/compiler-fixtures/foo.fixture test/compiler')
},
requires: test('requires', '--compilers coffee:coffee-script/register ' +
'--require test/require/a.js ' +
'--require test/require/b.coffee ' +
'--require test/require/c.js ' +
'--require test/require/d.coffee ' +
'test/require/require.spec.js'),
reporters: test('reporters', 'test/reporters/*.spec.js'),
only: {
default: 'nps test.node.only.bdd test.node.only.tdd test.node.only.bddRequire',
bdd: test('only-bdd', '--ui bdd test/only/bdd.spec'),
tdd: test('only-tdd', '--ui tdd test/only/tdd.spec'),
bddRequire: test('only-bdd-require', '--ui qunit test/only/bdd-require.spec')
},
globalOnly: {
default: 'nps test.node.globalOnly.bdd test.node.globalOnly.tdd test.node.globalOnly.qunit',
bdd: test('global-only-bdd', '--ui bdd test/only/global/bdd.spec'),
tdd: test('global-only-tdd', '--ui tdd test/only/global/tdd.spec'),
qunit: test('global-only-qunit', '--ui qunit test/only/global/qunit.spec')
}
},
browser: {
default: 'nps ' +
'clean ' +
'build.mochajs ' +
'test.browser.unit ' +
'test.browser.bdd ' +
'test.browser.tdd ' +
'test.browser.qunit ' +
'test.browser.esm',
unit: `NODE_PATH=. ${KARMA} start --single-run`,
bdd: 'MOCHA_TEST=bdd nps test.browser.unit',
tdd: 'MOCHA_TEST=tdd nps test.browser.unit',
qunit: 'MOCHA_TEST=qunit nps test.browser.unit',
esm: 'MOCHA_TEST=esm nps test.browser.unit'
},
nonTTY: {
default: 'nps test.nonTTY.dot test.nonTTY.list test.nonTTY.spec',
dot: test('non-tty-dot', '--reporter dot test/interfaces/bdd.spec 2>&1 > /tmp/dot.out && echo "dot:" && cat /tmp/dot.out'),
list: test('non-tty-list', '--reporter list test/interfaces/bdd.spec 2>&1 > /tmp/list.out && echo "list:" && cat /tmp/list.out'),
spec: test('non-tty-dot', '--reporter spec test/interfaces/bdd.spec 2>&1 > /tmp/spec.out && echo "spec:" && cat /tmp/spec.out')
}
},
tm: `open editors/${TM_BUNDLE}`,
prepublishOnly: 'nps test clean build',
coveralls: 'nyc report --reporter=text-lcov | coveralls',
prebuildDocs: 'rm -rf docs/_dist && node scripts/docs-update-toc.js',
buildDocs: 'nps prebuildDocs && bundle exec jekyll build --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts && nps postbuildDocs',
postbuildDocs: 'buildProduction docs/_site/index.html --outroot docs/_dist --canonicalroot https://mochajs.org/ --optimizeimages --svgo --inlinehtmlimage 9400 --inlinehtmlscript 0 --asyncscripts && cp docs/_headers docs/_dist/_headers && node scripts/netlify-headers.js >> docs/_dist/_headers',
prewatchDocs: 'node scripts/docs-update-toc.js',
watchDocs: 'nps prewatchDocs && bundle exec jekyll serve --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts --watch',
}
};
13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,8 @@
"node": ">= 4.0.0"
},
"scripts": {
"lint": "eslint . bin/*",
"markdownlint": "markdownlint \"*.md\" \"docs/**/*.md\" \".github/*.md\"",
"test": "make clean && make test",
"prepublishOnly": "npm test && make clean && make mocha.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"prebuildDocs": "rm -rf docs/_dist && node scripts/docs-update-toc.js",
"buildDocs": "bundle exec jekyll build --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts",
"postbuildDocs": "buildProduction docs/_site/index.html --outroot docs/_dist --canonicalroot https://mochajs.org/ --optimizeimages --svgo --inlinehtmlimage 9400 --inlinehtmlscript 0 --asyncscripts && cp docs/_headers docs/_dist/_headers && node scripts/netlify-headers.js >> docs/_dist/_headers",
"prewatchDocs": "node scripts/docs-update-toc.js",
"watchDocs": "bundle exec jekyll serve --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts --watch"
"start": "nps",
"test": "nps test"
},
"dependencies": {
"browser-stdout": "1.3.0",
Expand Down Expand Up @@ -347,6 +339,7 @@
"karma-sauce-launcher": "^1.2.0",
"markdown-toc": "^1.2.0",
"markdownlint-cli": "^0.6.0",
"nps": "^5.7.1",
"nyc": "^11.2.1",
"rimraf": "^2.5.2",
"svgo": "^0.7.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis-before-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
mkdir -p .karma

# ensure we are building a non-broken bundle for AMD
make mocha.js && [[ -z "$(grep 'define.amd' mocha.js)" ]] || exit 1
npm start build.mochajs && [[ -z "$(grep 'define.amd' mocha.js)" ]] || exit 1

0 comments on commit 7c830a6

Please sign in to comment.