From 185e4e537670b3179accb0016a075c8d708ec0fe Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 6 Jul 2018 13:27:22 +0200 Subject: [PATCH 1/3] add nyc and coveralls --- .gitignore | 2 ++ .travis.yml | 2 ++ README.md | 1 + package.json | 9 ++++++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3c3629e6..1fd04daf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ node_modules +coverage +.nyc_output diff --git a/.travis.yml b/.travis.yml index 24dc9e8d..4406cf47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,3 +21,5 @@ matrix: script: - DEBUG=airtap:* npm run $CMD + +after_success: npm run coverage diff --git a/README.md b/README.md index 218ff230..8b7d58a3 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ![Node version](https://img.shields.io/node/v/abstract-leveldown.svg) [![Travis](https://travis-ci.org/Level/abstract-leveldown.svg?branch=master)](http://travis-ci.org/Level/abstract-leveldown) [![david](https://david-dm.org/Level/abstract-leveldown.svg)](https://david-dm.org/level/abstract-leveldown) +[![Coverage Status](https://coveralls.io/repos/github/Level/abstract-leveldown/badge.svg)](https://coveralls.io/github/Level/abstract-leveldown) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![npm](https://img.shields.io/npm/dm/abstract-leveldown.svg)](https://www.npmjs.com/package/abstract-leveldown) diff --git a/package.json b/package.json index 570d15ee..762c045b 100644 --- a/package.json +++ b/package.json @@ -20,14 +20,17 @@ }, "devDependencies": { "airtap": "0.1.0", + "coveralls": "~3.0.2", + "nyc": "~12.0.2", "sinon": "^6.0.0", "standard": "^11.0.0", "tape": "^4.7.0" }, "scripts": { - "test": "standard && node test.js", - "test-browsers": "airtap --loopback airtap.local test.js", - "test-browser-local": "airtap --local test.js" + "test": "standard && nyc node test.js", + "test-browsers": "airtap --coverage --loopback airtap.local test.js", + "test-browser-local": "airtap --coverage --local test.js", + "coverage": "nyc report --reporter=text-lcov | coveralls" }, "browser": { "./test-common.js": "./test-common-browser.js" From ee7e63635cdb454b6fa6f1e47cbf790e6ea03991 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 7 Jul 2018 12:59:01 +0200 Subject: [PATCH 2/3] rename abstract/ to test/ --- README.md | 2 +- UPGRADING.md | 16 ++++++ test.js | 56 +++++++++---------- {abstract => test}/batch-test.js | 0 {abstract => test}/chained-batch-test.js | 0 {abstract => test}/close-test.js | 0 {abstract => test}/del-test.js | 0 {abstract => test}/get-test.js | 0 .../iterator-no-snapshot-test.js | 0 {abstract => test}/iterator-range-test.js | 0 {abstract => test}/iterator-snapshot-test.js | 0 {abstract => test}/iterator-test.js | 0 {abstract => test}/leveldown-test.js | 0 {abstract => test}/open-test.js | 0 {abstract => test}/put-get-del-test.js | 0 {abstract => test}/put-test.js | 0 {abstract => test}/util.js | 0 17 files changed, 45 insertions(+), 29 deletions(-) rename {abstract => test}/batch-test.js (100%) rename {abstract => test}/chained-batch-test.js (100%) rename {abstract => test}/close-test.js (100%) rename {abstract => test}/del-test.js (100%) rename {abstract => test}/get-test.js (100%) rename {abstract => test}/iterator-no-snapshot-test.js (100%) rename {abstract => test}/iterator-range-test.js (100%) rename {abstract => test}/iterator-snapshot-test.js (100%) rename {abstract => test}/iterator-test.js (100%) rename {abstract => test}/leveldown-test.js (100%) rename {abstract => test}/open-test.js (100%) rename {abstract => test}/put-get-del-test.js (100%) rename {abstract => test}/put-test.js (100%) rename {abstract => test}/util.js (100%) diff --git a/README.md b/README.md index 8b7d58a3..0991c56b 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Provided with the current instance of `AbstractLevelDOWN` by default. ## Test Suite -To prove that your implementation is `abstract-leveldown` compliant, include the test suite found in `abstract/`. For examples please see the test suites of implementations like [`leveldown`](https://github.com/Level/leveldown), [`level-js`](https://github.com/Level/level-js) or [`memdown`](https://github.com/Level/memdown). +To prove that your implementation is `abstract-leveldown` compliant, include the test suite found in `test/`. For examples please see the test suites of implementations like [`leveldown`](https://github.com/Level/leveldown), [`level-js`](https://github.com/Level/level-js) or [`memdown`](https://github.com/Level/memdown). As not every implementation can be fully compliant due to limitations of its underlying storage, some tests may be skipped. diff --git a/UPGRADING.md b/UPGRADING.md index 75a0d067..7eace5ca 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,6 +4,22 @@ This document describes breaking changes and how to upgrade. For a complete list ## Unreleased +### Abstract test suite has moved + +If you previously did: + +```js +require('abstract-leveldown/abstract/get-test') +require('abstract-leveldown/abstract/put-test') // etc +``` + +You must now do: + +```js +require('abstract-leveldown/test/get-test') +require('abstract-leveldown/test/put-test') // etc +``` + ### Default `testCommon` is for disk-based, Node.js implementations only If your implementation or its target environment doesn't meet these criteria, you must implement a custom `testCommon`. diff --git a/test.js b/test.js index b8909e3a..221d8898 100644 --- a/test.js +++ b/test.js @@ -16,46 +16,46 @@ function factory (location) { * Compatibility with basic LevelDOWN API */ -require('./abstract/leveldown-test').args(factory, test) +require('./test/leveldown-test').args(factory, test) -require('./abstract/open-test').args(factory, test, testCommon) +require('./test/open-test').args(factory, test, testCommon) -require('./abstract/del-test').setUp(factory, test, testCommon) -require('./abstract/del-test').args(test) +require('./test/del-test').setUp(factory, test, testCommon) +require('./test/del-test').args(test) -require('./abstract/get-test').setUp(factory, test, testCommon) -require('./abstract/get-test').args(test) +require('./test/get-test').setUp(factory, test, testCommon) +require('./test/get-test').args(test) -require('./abstract/put-test').setUp(factory, test, testCommon) -require('./abstract/put-test').args(test) +require('./test/put-test').setUp(factory, test, testCommon) +require('./test/put-test').args(test) -require('./abstract/put-get-del-test').setUp(factory, test, testCommon) -require('./abstract/put-get-del-test').errorKeys(test) -// require('./abstract/put-get-del-test').nonErrorKeys(test, testCommon) -require('./abstract/put-get-del-test').errorValues() -require('./abstract/put-get-del-test').tearDown(test, testCommon) +require('./test/put-get-del-test').setUp(factory, test, testCommon) +require('./test/put-get-del-test').errorKeys(test) +// require('./test/put-get-del-test').nonErrorKeys(test, testCommon) +require('./test/put-get-del-test').errorValues() +require('./test/put-get-del-test').tearDown(test, testCommon) -require('./abstract/batch-test').setUp(factory, test, testCommon) -require('./abstract/batch-test').args(test) +require('./test/batch-test').setUp(factory, test, testCommon) +require('./test/batch-test').args(test) -require('./abstract/chained-batch-test').setUp(factory, test, testCommon) -require('./abstract/chained-batch-test').args(test) +require('./test/chained-batch-test').setUp(factory, test, testCommon) +require('./test/chained-batch-test').args(test) -require('./abstract/close-test').close(factory, test, testCommon) +require('./test/close-test').close(factory, test, testCommon) -require('./abstract/iterator-test').setUp(factory, test, testCommon) -require('./abstract/iterator-test').args(test) -require('./abstract/iterator-test').sequence(test) -require('./abstract/iterator-test').tearDown(test, testCommon) +require('./test/iterator-test').setUp(factory, test, testCommon) +require('./test/iterator-test').args(test) +require('./test/iterator-test').sequence(test) +require('./test/iterator-test').tearDown(test, testCommon) -require('./abstract/iterator-range-test').setUp(factory, test, testCommon, []) -require('./abstract/iterator-range-test').tearDown(test, testCommon) +require('./test/iterator-range-test').setUp(factory, test, testCommon, []) +require('./test/iterator-range-test').tearDown(test, testCommon) -require('./abstract/iterator-snapshot-test').setUp(factory, test, testCommon) -require('./abstract/iterator-snapshot-test').tearDown(test, testCommon) +require('./test/iterator-snapshot-test').setUp(factory, test, testCommon) +require('./test/iterator-snapshot-test').tearDown(test, testCommon) -require('./abstract/iterator-no-snapshot-test').setUp(factory, test, testCommon) -require('./abstract/iterator-no-snapshot-test').tearDown(test, testCommon) +require('./test/iterator-no-snapshot-test').setUp(factory, test, testCommon) +require('./test/iterator-no-snapshot-test').tearDown(test, testCommon) function implement (ctor, methods) { function Test () { diff --git a/abstract/batch-test.js b/test/batch-test.js similarity index 100% rename from abstract/batch-test.js rename to test/batch-test.js diff --git a/abstract/chained-batch-test.js b/test/chained-batch-test.js similarity index 100% rename from abstract/chained-batch-test.js rename to test/chained-batch-test.js diff --git a/abstract/close-test.js b/test/close-test.js similarity index 100% rename from abstract/close-test.js rename to test/close-test.js diff --git a/abstract/del-test.js b/test/del-test.js similarity index 100% rename from abstract/del-test.js rename to test/del-test.js diff --git a/abstract/get-test.js b/test/get-test.js similarity index 100% rename from abstract/get-test.js rename to test/get-test.js diff --git a/abstract/iterator-no-snapshot-test.js b/test/iterator-no-snapshot-test.js similarity index 100% rename from abstract/iterator-no-snapshot-test.js rename to test/iterator-no-snapshot-test.js diff --git a/abstract/iterator-range-test.js b/test/iterator-range-test.js similarity index 100% rename from abstract/iterator-range-test.js rename to test/iterator-range-test.js diff --git a/abstract/iterator-snapshot-test.js b/test/iterator-snapshot-test.js similarity index 100% rename from abstract/iterator-snapshot-test.js rename to test/iterator-snapshot-test.js diff --git a/abstract/iterator-test.js b/test/iterator-test.js similarity index 100% rename from abstract/iterator-test.js rename to test/iterator-test.js diff --git a/abstract/leveldown-test.js b/test/leveldown-test.js similarity index 100% rename from abstract/leveldown-test.js rename to test/leveldown-test.js diff --git a/abstract/open-test.js b/test/open-test.js similarity index 100% rename from abstract/open-test.js rename to test/open-test.js diff --git a/abstract/put-get-del-test.js b/test/put-get-del-test.js similarity index 100% rename from abstract/put-get-del-test.js rename to test/put-get-del-test.js diff --git a/abstract/put-test.js b/test/put-test.js similarity index 100% rename from abstract/put-test.js rename to test/put-test.js diff --git a/abstract/util.js b/test/util.js similarity index 100% rename from abstract/util.js rename to test/util.js From 5e4aa611eff4a5dac5b72eb619d7d13ee61e395b Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 7 Jul 2018 13:06:14 +0200 Subject: [PATCH 3/3] rename test-common[-browser].js to test/common[-browser].js --- UPGRADING.md | 2 +- package.json | 2 +- test.js | 2 +- test/batch-test.js | 2 +- test/chained-batch-test.js | 2 +- test/close-test.js | 2 +- test-common-browser.js => test/common-browser.js | 0 test-common.js => test/common.js | 0 test/del-test.js | 2 +- test/get-test.js | 2 +- test/iterator-no-snapshot-test.js | 2 +- test/iterator-range-test.js | 2 +- test/iterator-snapshot-test.js | 2 +- test/iterator-test.js | 2 +- test/open-test.js | 2 +- test/put-get-del-test.js | 2 +- test/put-test.js | 2 +- 17 files changed, 15 insertions(+), 15 deletions(-) rename test-common-browser.js => test/common-browser.js (100%) rename test-common.js => test/common.js (100%) diff --git a/UPGRADING.md b/UPGRADING.md index 7eace5ca..2cf1d417 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -35,7 +35,7 @@ const testCommon = require('abstract-leveldown/testCommon') You must now do: ```js -const testCommon = require('abstract-leveldown/test-common') +const testCommon = require('abstract-leveldown/test/common') ``` ### Default `testCommon` uses unique temporary directories diff --git a/package.json b/package.json index 762c045b..430ec2fc 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "coverage": "nyc report --reporter=text-lcov | coveralls" }, "browser": { - "./test-common.js": "./test-common-browser.js" + "./test/common.js": "./test/common-browser.js" }, "license": "MIT", "engines": { diff --git a/test.js b/test.js index 221d8898..8791c4d4 100644 --- a/test.js +++ b/test.js @@ -3,7 +3,7 @@ var test = require('tape') var sinon = require('sinon') var inherits = require('util').inherits -var testCommon = require('./test-common') +var testCommon = require('./test/common') var AbstractLevelDOWN = require('./').AbstractLevelDOWN var AbstractIterator = require('./').AbstractIterator var AbstractChainedBatch = require('./').AbstractChainedBatch diff --git a/test/batch-test.js b/test/batch-test.js index d15d926e..b2c0a6c3 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -267,7 +267,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.batch(test) diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js index 0ea1039e..a46508f2 100644 --- a/test/chained-batch-test.js +++ b/test/chained-batch-test.js @@ -255,7 +255,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.batch(test, testCommon) diff --git a/test/close-test.js b/test/close-test.js index a1e5b5cc..e37bc4d4 100644 --- a/test/close-test.js +++ b/test/close-test.js @@ -1,5 +1,5 @@ module.exports.close = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') test('test close()', function (t) { var db = leveldown(testCommon.location()) diff --git a/test-common-browser.js b/test/common-browser.js similarity index 100% rename from test-common-browser.js rename to test/common-browser.js diff --git a/test-common.js b/test/common.js similarity index 100% rename from test-common.js rename to test/common.js diff --git a/test/del-test.js b/test/del-test.js index f213f481..55895f80 100644 --- a/test/del-test.js +++ b/test/del-test.js @@ -89,7 +89,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.del(test) diff --git a/test/get-test.js b/test/get-test.js index 860667aa..f59acf69 100644 --- a/test/get-test.js +++ b/test/get-test.js @@ -166,7 +166,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.get(test) diff --git a/test/iterator-no-snapshot-test.js b/test/iterator-no-snapshot-test.js index 65b487b3..d2889abf 100644 --- a/test/iterator-no-snapshot-test.js +++ b/test/iterator-no-snapshot-test.js @@ -64,7 +64,7 @@ exports.tearDown = function (test, testCommon) { } exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') exports.setUp(leveldown, test, testCommon) exports.noSnapshot(leveldown, test, testCommon) exports.tearDown(test, testCommon) diff --git a/test/iterator-range-test.js b/test/iterator-range-test.js index f67a813f..880b87ce 100644 --- a/test/iterator-range-test.js +++ b/test/iterator-range-test.js @@ -355,7 +355,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') var data = (function () { var d = [] diff --git a/test/iterator-snapshot-test.js b/test/iterator-snapshot-test.js index edf3b4f0..4b2e6fcb 100644 --- a/test/iterator-snapshot-test.js +++ b/test/iterator-snapshot-test.js @@ -83,7 +83,7 @@ exports.tearDown = function (test, testCommon) { } exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') exports.setUp(leveldown, test, testCommon) exports.snapshot(leveldown, test, testCommon) exports.tearDown(test, testCommon) diff --git a/test/iterator-test.js b/test/iterator-test.js index 461050cb..8302d8da 100644 --- a/test/iterator-test.js +++ b/test/iterator-test.js @@ -162,7 +162,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.sequence(test) diff --git a/test/open-test.js b/test/open-test.js index 9407d255..8e98a024 100644 --- a/test/open-test.js +++ b/test/open-test.js @@ -114,7 +114,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(test, testCommon) module.exports.args(leveldown, test, testCommon) module.exports.open(leveldown, test, testCommon) diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js index 6f04768a..d50f1e22 100644 --- a/test/put-get-del-test.js +++ b/test/put-get-del-test.js @@ -168,7 +168,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.errorKeys(test) module.exports.nonErrorKeys(test) diff --git a/test/put-test.js b/test/put-test.js index c51a446a..ab2c314a 100644 --- a/test/put-test.js +++ b/test/put-test.js @@ -127,7 +127,7 @@ module.exports.tearDown = function (test, testCommon) { } module.exports.all = function (leveldown, test, testCommon) { - testCommon = testCommon || require('../test-common') + testCommon = testCommon || require('./common') module.exports.setUp(leveldown, test, testCommon) module.exports.args(test) module.exports.put(test)