[Pkg-javascript-commits] [node-leveldown] 18/492: simplify setUp/tearDown, extend timeout

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 9cc3ea4755e27cb971c56a2b2417c036f74291c0
Author: Rod Vagg <rod at vagg.org>
Date:   Thu Aug 16 09:50:11 2012 +1000

    simplify setUp/tearDown, extend timeout
---
 .jshintrc                 | 30 ++++++++++++++++++++++++++++++
 package.json              |  3 +++
 test/binary-test.js       | 12 ++++--------
 test/common.js            | 13 ++++++++++---
 test/copy-test.js         | 13 +++----------
 test/read-stream-test.js  | 10 +++-------
 test/simple-test.js       | 13 +++----------
 test/write-stream-test.js | 11 ++++-------
 8 files changed, 60 insertions(+), 45 deletions(-)

diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..9fcbd73
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,30 @@
+{
+    "predef": [ "assert", "refute", "define" ]
+  , "boss": true
+  , "bitwise": true
+  , "shadow": true
+  , "trailing": true
+  , "immed": true
+  , "latedef": true
+  , "forin": false
+  , "curly": false
+  , "debug": true
+  , "devel": false
+  , "evil": true
+  , "regexp": false
+  , "undef": true
+  , "sub": true
+  , "white": false
+  , "indent": 2
+  , "trailing": true
+  , "asi": true
+  , "laxbreak": true
+  , "eqnull": true
+  , "browser": true
+  , "node": true
+  , "laxcomma": true
+  , "proto": true
+  , "expr": true
+  , "es5": true
+  , "strict": false
+}
diff --git a/package.json b/package.json
index 894f341..d78addc 100644
--- a/package.json
+++ b/package.json
@@ -5,11 +5,14 @@
   , "dependencies"    : {
         "errno"         : ">=0.0.2"
       , "bindings"      : "~1.0.0"
+      , "concat-stream" : ">=0.0.8"
     }
   , "devDependencies" : {
         "buster"        : "*"
       , "rimraf"        : "*"
       , "async"         : "*"
+      , "fstream"       : "*"
+      , "tar"           : "*"
     }
   , "scripts"         : {
       "test"            : "./node_modules/.bin/buster-test"
diff --git a/test/binary-test.js b/test/binary-test.js
index 91ad7db..7f86ebd 100644
--- a/test/binary-test.js
+++ b/test/binary-test.js
@@ -1,7 +1,7 @@
-/*global cleanUp:true, openTestDatabase:true, loadBinaryTestData:true, binaryTestDataMD5Sum:true, checkBinaryTestData:true*/
-
 /* Copyright (c) 2012 Rod Vagg <@rvagg> */
 
+/*global commonSetUp:true, commonTearDown:true, loadBinaryTestData:true, binaryTestDataMD5Sum:true, checkBinaryTestData:true*/
+
 var buster  = require('buster')
   , assert  = buster.assert
   , levelup = require('../lib/levelup.js')
@@ -14,9 +14,7 @@ require('./common.js')
 
 buster.testCase('Binary API', {
     'setUp': function (done) {
-      this.cleanupDirs = []
-      this.closeableDatabases = []
-      this.openTestDatabase = openTestDatabase.bind(this)
+      commonSetUp.call(this)
       loadBinaryTestData(function (err, data) {
         refute(err)
         this.testData = data
@@ -24,9 +22,7 @@ buster.testCase('Binary API', {
       }.bind(this))
     }
 
-  , 'tearDown': function (done) {
-      cleanUp(this.closeableDatabases, this.cleanupDirs, done)
-    }
+  , 'tearDown': commonTearDown
 
   , 'sanity check on test data': function (done) {
       assert(Buffer.isBuffer(this.testData))
diff --git a/test/common.js b/test/common.js
index 54e4535..05ef443 100644
--- a/test/common.js
+++ b/test/common.js
@@ -52,14 +52,14 @@ global.openTestDatabase = function (location, callback) {
   }.bind(this))
 }
 
-global.cleanUp = function (closeableDatabases, cleanupDirs, callback) {
+global.commonTearDown = function (done) {
   async.forEach(
-      closeableDatabases
+      this.closeableDatabases
     , function (db, callback) {
         db.close(callback)
       }
     , function () {
-        async.forEach(cleanupDirs, rimraf, callback)
+        async.forEach(this.cleanupDirs, rimraf, done)
       }.bind(this)
   )
 }
@@ -84,4 +84,11 @@ global.checkBinaryTestData = function (testData, callback) {
       })
     })
   })
+}
+
+global.commonSetUp = function () {
+  this.cleanupDirs = []
+  this.closeableDatabases = []
+  this.openTestDatabase = openTestDatabase.bind(this)
+  this.timeout = 500
 }
\ No newline at end of file
diff --git a/test/copy-test.js b/test/copy-test.js
index 3b6b536..9ddd557 100644
--- a/test/copy-test.js
+++ b/test/copy-test.js
@@ -1,6 +1,6 @@
 /* Copyright (c) 2012 Rod Vagg <@rvagg> */
 
-/*global cleanUp:true, openTestDatabase:true*/
+/*global commonSetUp:true, commonTearDown:true*/
 
 var buster  = require('buster')
   , assert  = buster.assert
@@ -11,15 +11,8 @@ var buster  = require('buster')
   , fs      = require('fs')
 
 buster.testCase('Copy', {
-    'setUp': function () {
-      this.cleanupDirs = []
-      this.closeableDatabases = []
-      this.openTestDatabase = openTestDatabase.bind(this)
-    }
-
-  , 'tearDown': function (done) {
-      cleanUp(this.closeableDatabases, this.cleanupDirs, done)
-    }
+    'setUp': commonSetUp
+  , 'tearDown': commonTearDown
 
   , 'copy full database': function (done) {
       var sourceData = []
diff --git a/test/read-stream-test.js b/test/read-stream-test.js
index 98e844c..db41447 100644
--- a/test/read-stream-test.js
+++ b/test/read-stream-test.js
@@ -1,6 +1,6 @@
 /* Copyright (c) 2012 Rod Vagg <@rvagg> */
 
-/*global cleanUp:true, openTestDatabase:true*/
+/*global commonSetUp:true, commonTearDown:true*/
 
 var buster  = require('buster')
   , assert  = buster.assert
@@ -13,9 +13,7 @@ var buster  = require('buster')
 
 buster.testCase('ReadStream', {
     'setUp': function () {
-      this.cleanupDirs = []
-      this.closeableDatabases = []
-      this.openTestDatabase = openTestDatabase.bind(this)
+      commonSetUp.call(this)
 
       this.readySpy   = this.spy()
       this.dataSpy    = this.spy()
@@ -50,9 +48,7 @@ buster.testCase('ReadStream', {
       }.bind(this)
     }
 
-  , 'tearDown': function (done) {
-      cleanUp(this.closeableDatabases, this.cleanupDirs, done)
-    }
+  , 'tearDown': commonTearDown
 
   //TODO: test various encodings
 
diff --git a/test/simple-test.js b/test/simple-test.js
index c6a79ff..77d5c32 100644
--- a/test/simple-test.js
+++ b/test/simple-test.js
@@ -1,6 +1,6 @@
 /* Copyright (c) 2012 Rod Vagg <@rvagg> */
 
-/*global cleanUp:true, openTestDatabase:true*/
+/*global commonSetUp:true, commonTearDown:true*/
 
 var buster  = require('buster')
   , assert  = buster.assert
@@ -11,15 +11,8 @@ var buster  = require('buster')
   , fs      = require('fs')
 
 buster.testCase('Basic API', {
-    'setUp': function () {
-      this.cleanupDirs = []
-      this.closeableDatabases = []
-      this.openTestDatabase = openTestDatabase.bind(this)
-    }
-
-  , 'tearDown': function (done) {
-      cleanUp(this.closeableDatabases, this.cleanupDirs, done)
-    }
+    'setUp': commonSetUp
+  , 'tearDown': commonTearDown
 
   , 'createDatabase()': function () {
       var db
diff --git a/test/write-stream-test.js b/test/write-stream-test.js
index 7822c6b..5098030 100644
--- a/test/write-stream-test.js
+++ b/test/write-stream-test.js
@@ -1,6 +1,6 @@
 /* Copyright (c) 2012 Rod Vagg <@rvagg> */
 
-/*global cleanUp:true, openTestDatabase:true*/
+/*global commonSetUp:true, commonTearDown:true*/
 
 var buster  = require('buster')
   , assert  = buster.assert
@@ -13,9 +13,8 @@ var buster  = require('buster')
 
 buster.testCase('WriteStream', {
     'setUp': function () {
-      this.cleanupDirs = []
-      this.closeableDatabases = []
-      this.openTestDatabase = openTestDatabase.bind(this)
+      commonSetUp.call(this)
+
       this.timeout = 1000
 
       this.sourceData = []
@@ -45,9 +44,7 @@ buster.testCase('WriteStream', {
       }
     }
 
-  , 'tearDown': function (done) {
-      cleanUp(this.closeableDatabases, this.cleanupDirs, done)
-    }
+  , 'tearDown': commonTearDown
 
   //TODO: test various encodings
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list