You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by gl...@apache.org on 2018/08/14 13:28:16 UTC
[couchdb-nano] branch master updated: wip: stop depending on
tape-it (#105)
This is an automated email from the ASF dual-hosted git repository.
glynnbird pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
The following commit(s) were added to refs/heads/master by this push:
new 3732c69 wip: stop depending on tape-it (#105)
3732c69 is described below
commit 3732c69318a6ef9ef7af7735bccbb7de4a600b76
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Aug 14 15:28:14 2018 +0200
wip: stop depending on tape-it (#105)
tape-it should have moved over with nano, it’s a tape harness config,
but binds us to an old version of tape. I tried a simple copy and paste,
while keeping the tape version, but getting npm t issues. This is a
three-step process:
1. copy `dscape/tape-it/index.js` to `test/helpers/harness.js`
2. update the `require` in `test/helpers/integration.js`
3. make tests work
It leads us to the fun situation where our integration tests are run with
tape version ^3.0.1 and the rest with 4.6.2.
---
package.json | 3 +-
tests/helpers/harness.js | 72 ++++++++++++++++++++++++++++++++++++++++++++
tests/helpers/integration.js | 2 +-
3 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index f8f1cd2..beb36f5 100644
--- a/package.json
+++ b/package.json
@@ -31,8 +31,7 @@
"jshint": "^2.9.4",
"jscs": "^3.0.7",
"nock": "^9.0.0",
- "endswith": "^0.0.0",
- "tape-it": "^0.3.1"
+ "endswith": "^0.0.0"
},
"scripts": {
"test": "bash scripts/run_couchdb_on_travis.sh; npm run mocha; bash scripts/stop_couchdb_on_travis.sh",
diff --git a/tests/helpers/harness.js b/tests/helpers/harness.js
new file mode 100644
index 0000000..4f04f6b
--- /dev/null
+++ b/tests/helpers/harness.js
@@ -0,0 +1,72 @@
+'use strict';
+
+var test = require('tape');
+
+var nextTick = typeof setImmediate !== 'undefined' ?
+ setImmediate : process.nextTick;
+
+function noop(){}
+
+module.exports = function (opts) {
+ var invoked = false;
+ var id = opts.id;
+ var testPrefix = id || '';
+
+ var harness = {};
+
+ harness.tests = [];
+ harness.checkLeaks = typeof opts.checkLeaks === 'boolean' ?
+ opts.checkLeaks : true;
+ harness.globalCount = Object.keys(global).length;
+
+ harness.timeout = +(opts.timeout || 200);
+ harness.locals = opts.locals || {};
+
+ //
+ // locals must be available here
+ //
+ harness.setup = opts.setup || noop;
+ harness.teardown = opts.teardown || noop;
+
+ function runTest(name, next, onEnd) {
+ test(testPrefix + '\n## ' + name, function (assert) {
+
+ nextTick(function() { next.call(harness.locals, assert) });
+
+ var tmout = setTimeout(function () {
+ assert.fail('timed out');
+ assert.end();
+ }, harness.timeout);
+
+ assert.on('end', function () {
+ if(onEnd) {
+ onEnd(assert);
+ }
+ clearTimeout(tmout);
+ });
+ });
+ }
+
+ harness.it = function (name, next) {
+ harness.tests.push({name: name, next: next});
+ if (!invoked) {
+ invoked = true;
+ nextTick(function() {
+ runTest('setup', harness.setup);
+ harness.tests.forEach(function(elem) {
+ runTest(elem.name, elem.next);
+ });
+ runTest('teardown', harness.teardown, function (assert) {
+ if (harness.checkLeaks) {
+ assert.deepEqual(Object.keys(global)
+ .splice(harness.globalCount, Number.MAX_VALUE),
+ [], 'No leaks');
+ }
+ });
+ });
+ }
+ };
+
+ return harness;
+
+};
diff --git a/tests/helpers/integration.js b/tests/helpers/integration.js
index 340c72f..a4bfadd 100644
--- a/tests/helpers/integration.js
+++ b/tests/helpers/integration.js
@@ -15,7 +15,7 @@
const async = require('async');
const debug = require('debug');
const path = require('path');
-const harness = require('tape-it');
+const harness = require('./harness');
const endsWith = require('endswith');
const cfg = require('../fixtures/cfg');
const nano = require('../../lib/nano');