From f8eba17c4808e3a91c8dd47341806ed19ec4305e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Vind?= Date: Wed, 9 Nov 2016 12:50:19 -0800 Subject: [PATCH] Make it possible to run test suite with and without sync --- scripts/test.sh | 16 ++++++++++++++-- tests/package.json | 5 +++-- tests/spec/sync_tests.js | 34 ++++++++++++++++++++++++++++++++++ tests/spec/unit_tests.js | 15 --------------- 4 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 tests/spec/sync_tests.js diff --git a/scripts/test.sh b/scripts/test.sh index 29440257..38b47b2f 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -184,10 +184,22 @@ case "$TARGET" in pushd "$SRCROOT/tests" npm install - npm test + npm run test popd stop_server ;; +"node-nosync") + npm install --build-from-source + + # Change to a temp directory. + cd "$(mktemp -q -d -t realm.node.XXXXXX)" + trap "rm -rf '$PWD'" EXIT + + pushd "$SRCROOT/tests" + npm install + npm run test-nosync + popd + ;; "test-runners") npm install --build-from-source @@ -221,7 +233,7 @@ case "$TARGET" in pushd "$SRCROOT/tests" npm install - npm run test-sync + npm run test-sync-integration popd ;; *) diff --git a/tests/package.json b/tests/package.json index 4dea192f..a137ee93 100644 --- a/tests/package.json +++ b/tests/package.json @@ -13,8 +13,9 @@ "url-parse": "^1.1.7" }, "scripts": { - "test": "jasmine spec/unit_tests.js", - "test-sync": "jasmine spec/sync_integration_tests.js", + "test": "jasmine spec/unit_tests.js spec/sync_tests.js", + "test-nosync": "jasmine spec/unit_tests.js", + "test-sync-integration": "jasmine spec/sync_integration_tests.js", "postinstall": "rm -f node_modules/realm && ln -s ../.. node_modules/realm" } } diff --git a/tests/spec/sync_tests.js b/tests/spec/sync_tests.js new file mode 100644 index 00000000..ef7206e9 --- /dev/null +++ b/tests/spec/sync_tests.js @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2016 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +/* eslint-env es6, node */ +/* eslint-disable no-console */ + +'use strict'; + +const Realm = require('realm'); + +const userTests = require('../js/user-tests'); +describe('SyncTests', () => { + beforeEach(() => Realm.clearTestState()); + afterEach(() => Realm.clearTestState()); + + for (const testName in userTests) { + it(testName, (done) => userTests[testName]().catch((e) => fail(e)).then(done)); + } +}); diff --git a/tests/spec/unit_tests.js b/tests/spec/unit_tests.js index 2655924a..593c84dd 100644 --- a/tests/spec/unit_tests.js +++ b/tests/spec/unit_tests.js @@ -76,18 +76,3 @@ describe('AsyncTests', () => { afterEach(() => Realm.clearTestState()); }); - -const wn = require("child_process").spawn; -const terminate = require("terminate"); -const readline = require("readline"); -const tmp = require("tmp"); - -const userTests = require('../js/user-tests'); -describe('SyncTests', () => { - beforeEach(() => Realm.clearTestState()); - afterEach(() => Realm.clearTestState()); - - for (const testName in userTests) { - it(testName, (done) => userTests[testName]().catch((e) => fail(e)).then(done)); - } -});