refactor test.sh to use npm commands

fixed license-check npm command
added test-runners npm command
This commit is contained in:
blagoev 2017-03-22 14:01:09 +02:00
parent 1de37b5844
commit d23d60f272
5 changed files with 14 additions and 29 deletions

View File

@ -53,11 +53,17 @@
"install": "node-pre-gyp install --fallback-to-build",
"prepublish": "node scripts/prepublish.js",
"eslint": "npm install && npm run lint .",
"license-check": "license-checker --exclude \"MIT,ISC,BSD,Apache-2.0,BSD-2-Clause,BSD-3-Clause,WTFPL,Unlicense,(MIT AND CC-BY-3.0)\" | node scripts/handle-license-check.js",
"license-check": "npm install && license-checker --exclude \"MIT,ISC,BSD,Apache-2.0,BSD-2-Clause,BSD-3-Clause,WTFPL,Unlicense,(MIT AND CC-BY-3.0)\" | node scripts/handle-license-check.js",
"jsdoc:clean": "rimraf ./docs/output",
"jsdoc": "npm install && npm run jsdoc:clean && jsdoc -c docs/conf.json",
"node-tests": "npm install --build-from-source && cd tests && npm install && npm run test-nosync && cd ..",
"node-nosync-tests": "npm install --build-from-source && cd tests && npm install && npm run test-nosync && cd .."
"node-nosync-tests": "npm install --build-from-source && cd tests && npm install && npm run test-nosync && cd ..",
"test-runner:ava" :"cd tests/test-runners/ava && npm install && npm test",
"test-runner:mocha" :"cd tests/test-runners/mocha && npm install && npm test",
"test-runner:jest" :"cd tests/test-runners/jest && npm install && npm test",
"test-runners" : "npm run test-runner:ava && npm run test-runner:mocha && npm run test-runner:jest",
"isMac" : "node -p \"if (process.platform == 'darwin') { process.exit(0); } else { process.exit(-1); }\"",
"testMac" : "npm run isMac -s && echo this is mac || echo . "
},
"dependencies": {
"extract-zip": "^1.6.0",

View File

@ -244,9 +244,7 @@ rm -rf ~/.yarn-cache/npm-realm-*
case "$TARGET" in
"eslint")
[[ $CONFIGURATION == 'Debug' ]] && exit 0
npm install
npm run lint .
npm run eslint
;;
"eslint-ci")
[[ $CONFIGURATION == 'Debug' ]] && exit 0
@ -254,19 +252,10 @@ case "$TARGET" in
./node_modules/.bin/eslint -f checkstyle . > eslint.xml || true
;;
"license-check")
[[ $CONFIGURATION == 'Debug' ]] && exit 0
licenses=$(node_modules/.bin/license-checker --exclude "$ACCEPTED_LICENSES");
if [[ $licenses ]]; then
echo "Unknown license detected in dependency:"
node_modules/.bin/license-checker --exclude "$ACCEPTED_LICENSES"
exit 1
else
echo "All licenses are accepted"
fi
npm run license-check
;;
"jsdoc")
[[ $CONFIGURATION == 'Debug' ]] && exit 0
npm install
npm run jsdoc
;;
"realmjs")
@ -378,18 +367,8 @@ case "$TARGET" in
;;
"test-runners")
# Create a fake realm module that points to the source root so that test-runner tests can require('realm')
rm -rf "$SRCROOT/tests/test-runners/node_modules/realm"
mkdir -p "$SRCROOT/tests/test-runners/node_modules"
ln -s "../../.." "$SRCROOT/tests/test-runners/node_modules/realm"
npm install --build-from-source
for runner in ava mocha jest; do
pushd "$SRCROOT/tests/test-runners/$runner"
npm install
npm test
popd
done
npm run test-runners
;;
"object-store")
pushd src/object-store

View File

@ -1,7 +1,7 @@
import test from 'ava';
test('can require Realm', t => {
var realm = require('realm');
var realm = require('../../../../realm-js');
t.is('function', typeof realm);
t.is('Realm', realm.name);
});

View File

@ -1,6 +1,6 @@
describe('Realm', function() {
it('should be requirable', function() {
var realm = require('realm');
var realm = require('../../../../realm-js');
expect(typeof realm).toBe('function');
expect(realm.name).toBe('Realm');
});

View File

@ -2,7 +2,7 @@ var assert = require('assert');
describe('Realm', function() {
it('should be requirable', function() {
var realm = require('realm');
var realm = require('../../../../realm-js');
assert.equal(typeof realm, 'function');
assert.equal(realm.name, 'Realm');
});