[Pkg-javascript-commits] [node-browserify-zlib] 06/50: Browser test passing
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 13:09:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-browserify-zlib.
commit bf7f08007ebe313805318c51a0e5ce6c28332586
Author: dignifiedquire <dignifiedquire at gmail.com>
Date: Fri Apr 1 10:05:58 2016 -0400
Browser test passing
---
.gitignore | 4 +-
.travis.yml | 8 +++-
karma.conf.js | 6 ++-
npm-debug.log | 48 -----------------------
package.json | 1 +
src/binding.js | 33 ++++++++++++++--
test/test-zlib-close-after-write.js | 4 +-
test/test-zlib-dictionary-fail.js | 2 +-
test/test-zlib-flush.js | 3 +-
test/test-zlib-from-concatenated-gzip.js | 2 +-
test/test-zlib-from-gzip-with-trailing-garbage.js | 10 +++--
test/test-zlib-params.js | 1 -
test/test-zlib-truncated.js | 2 +-
test/test-zlib.js | 3 +-
14 files changed, 57 insertions(+), 70 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2752eb9..9ddf455 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-node_modules/
+node_modules
.DS_Store
+
+*.log
diff --git a/.travis.yml b/.travis.yml
index d23672e..ace9d77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,17 @@
language: node_js
node_js:
- - '4'
- - '5'
+ - "0.10"
+ - 4
+ - 5
- stable
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
+addons:
+ firefox: "latest"
+
script:
- npm run lint
- npm test
diff --git a/karma.conf.js b/karma.conf.js
index 5e8f992..50a418b 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -9,6 +9,10 @@ module.exports = function (karma) {
debug: true,
transform: ['brfs']
},
- browsers: process.env.TRAVIS ? ['Firefox', 'PhantomJS'] : ['Chrome'/*, 'PhantomJS'*/]
+ reporters: ['mocha-own'],
+ mochaOwnReporter: {
+ reporter: 'spec'
+ },
+ browsers: process.env.TRAVIS ? ['Firefox', 'PhantomJS'] : ['Chrome', 'PhantomJS']
})
}
diff --git a/npm-debug.log b/npm-debug.log
deleted file mode 100644
index 81556e8..0000000
--- a/npm-debug.log
+++ /dev/null
@@ -1,48 +0,0 @@
-0 info it worked if it ends with ok
-1 verbose cli [ '/Users/dignifiedquire/.nvm/versions/node/v5.7.0/bin/node',
-1 verbose cli '/Users/dignifiedquire/.nvm/versions/node/v5.7.0/bin/npm',
-1 verbose cli 'run',
-1 verbose cli 'test:browser' ]
-2 info using npm at 3.6.0
-3 info using node at v5.7.0
-4 verbose run-script [ 'pretest:browser', 'test:browser', 'posttest:browser' ]
-5 info lifecycle browserify-zlib at 0.1.4~pretest:browser: browserify-zlib at 0.1.4
-6 silly lifecycle browserify-zlib at 0.1.4~pretest:browser: no script for pretest:browser, continuing
-7 info lifecycle browserify-zlib at 0.1.4~test:browser: browserify-zlib at 0.1.4
-8 verbose lifecycle browserify-zlib at 0.1.4~test:browser: unsafe-perm in lifecycle true
-9 verbose lifecycle browserify-zlib at 0.1.4~test:browser: PATH: /Users/dignifiedquire/.nvm/versions/node/v5.7.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/dignifiedquire/opensource/ipfs/browserify-zlib/node_modules/.bin:/Users/dignifiedquire/.nvm/versions/node/v5.7.0/bin:/Users/dignifiedquire/.cargo/bin:/usr/local/texlive/2014/bin/x86_64-darwin:/Users/dignifiedquire/.cabal/bin:/usr/local/sbin:/usr/local/bin:/Users/dignifiedquire/.cask/bin:/Users/dignifiedquire/.rbenv/bin:/Users/dignified [...]
-10 verbose lifecycle browserify-zlib at 0.1.4~test:browser: CWD: /Users/dignifiedquire/opensource/ipfs/browserify-zlib
-11 silly lifecycle browserify-zlib at 0.1.4~test:browser: Args: [ '-c', 'karma start --single-run=true karma.conf.js' ]
-12 silly lifecycle browserify-zlib at 0.1.4~test:browser: Returned: code: 1 signal: null
-13 info lifecycle browserify-zlib at 0.1.4~test:browser: Failed to exec test:browser script
-14 verbose stack Error: browserify-zlib at 0.1.4 test:browser: `karma start --single-run=true karma.conf.js`
-14 verbose stack Exit status 1
-14 verbose stack at EventEmitter.<anonymous> (/Users/dignifiedquire/.nvm/versions/node/v5.7.0/lib/node_modules/npm/lib/utils/lifecycle.js:232:16)
-14 verbose stack at emitTwo (events.js:100:13)
-14 verbose stack at EventEmitter.emit (events.js:185:7)
-14 verbose stack at ChildProcess.<anonymous> (/Users/dignifiedquire/.nvm/versions/node/v5.7.0/lib/node_modules/npm/lib/utils/spawn.js:24:14)
-14 verbose stack at emitTwo (events.js:100:13)
-14 verbose stack at ChildProcess.emit (events.js:185:7)
-14 verbose stack at maybeClose (internal/child_process.js:827:16)
-14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
-15 verbose pkgid browserify-zlib at 0.1.4
-16 verbose cwd /Users/dignifiedquire/opensource/ipfs/browserify-zlib
-17 error Darwin 15.4.0
-18 error argv "/Users/dignifiedquire/.nvm/versions/node/v5.7.0/bin/node" "/Users/dignifiedquire/.nvm/versions/node/v5.7.0/bin/npm" "run" "test:browser"
-19 error node v5.7.0
-20 error npm v3.6.0
-21 error code ELIFECYCLE
-22 error browserify-zlib at 0.1.4 test:browser: `karma start --single-run=true karma.conf.js`
-22 error Exit status 1
-23 error Failed at the browserify-zlib at 0.1.4 test:browser script 'karma start --single-run=true karma.conf.js'.
-23 error Make sure you have the latest version of node.js and npm installed.
-23 error If you do, this is most likely a problem with the browserify-zlib package,
-23 error not with npm itself.
-23 error Tell the author that this fails on your system:
-23 error karma start --single-run=true karma.conf.js
-23 error You can get information on how to open an issue for this project with:
-23 error npm bugs browserify-zlib
-23 error Or if that isn't available, you can get their info via:
-23 error npm owner ls browserify-zlib
-23 error There is likely additional logging output above.
-24 verbose exit [ 1, true ]
diff --git a/package.json b/package.json
index 2777db4..b84f5ed 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"karma-chrome-launcher": "^0.2.3",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.2",
+ "karma-mocha-own-reporter": "^1.1.2",
"karma-phantomjs-launcher": "^1.0.0",
"mocha": "^2.4.5",
"phantomjs-prebuilt": "^2.1.7",
diff --git a/src/binding.js b/src/binding.js
index c7a7599..c20db37 100644
--- a/src/binding.js
+++ b/src/binding.js
@@ -42,7 +42,7 @@ Zlib.prototype.init = function (windowBits, level, memLevel, strategy, dictionar
this.level = level
this.memLevel = memLevel
this.strategy = strategy
- // dictionary not supported.
+ this.dictionary = dictionary
if (this.mode === exports.GZIP || this.mode === exports.GUNZIP) {
this.windowBits += 16
@@ -193,7 +193,7 @@ Zlib.prototype._write = function (flush, input, in_off, in_len, out, out_off, ou
}
if (status !== exports.Z_STREAM_END && status !== exports.Z_OK) {
- this._error(status)
+ this._error(status, flush)
}
this.write_in_progress = false
@@ -235,8 +235,33 @@ Zlib.prototype.reset = function () {
}
}
-Zlib.prototype._error = function (status) {
- this.onerror(msg[status] + ': ' + this.strm.msg, status)
+Zlib.prototype._error = function (status, flush) {
+ var errMsg
+
+ switch (status) {
+ case exports.Z_OK:
+ case exports.Z_BUF_ERROR:
+ if (this.strm.avail_out !== 0 && flush === exports.Z_FINISH) {
+ errMsg = 'unexpected end of file'
+ } else {
+ errMsg = msg[status]
+ }
+ break
+ case exports.Z_STREAM_END:
+ // normal statuses, not fatal
+ break
+ case exports.Z_NEED_DICT:
+ if (!this.dictionary) {
+ errMsg = 'Missing dictionary'
+ } else {
+ errMsg = 'Bad dictionary'
+ }
+ break
+ default:
+ errMsg = status[msg]
+ }
+
+ this.onerror(errMsg, status)
this.write_in_progress = false
if (this.pending_close) {
diff --git a/test/test-zlib-close-after-write.js b/test/test-zlib-close-after-write.js
index 838ed3a..a03d369 100755
--- a/test/test-zlib-close-after-write.js
+++ b/test/test-zlib-close-after-write.js
@@ -3,8 +3,8 @@
var zlib = require('../')
-describe('zlib', function () {
- it('closes after write', function (done) {
+describe('zlib - close after write', function () {
+ it('works', function (done) {
zlib.gzip('hello', function (err, out) {
if (err) throw err
var unzip = zlib.createGunzip()
diff --git a/test/test-zlib-dictionary-fail.js b/test/test-zlib-dictionary-fail.js
index 58e05b5..77e28b2 100644
--- a/test/test-zlib-dictionary-fail.js
+++ b/test/test-zlib-dictionary-fail.js
@@ -5,7 +5,7 @@ var assert = require('assert')
var common = require('./common')
var zlib = require('../')
-describe.skip('zlib - dictionary fails', function () {
+describe('zlib - dictionary fails', function () {
it('should fail on missing dictionary', function (done) {
// Should raise an error, not trigger an assertion in src/node_zlib.cc
var stream = zlib.createInflate()
diff --git a/test/test-zlib-flush.js b/test/test-zlib-flush.js
index 7930fa0..277eb42 100644
--- a/test/test-zlib-flush.js
+++ b/test/test-zlib-flush.js
@@ -1,7 +1,6 @@
/* eslint-env mocha */
'use strict'
-var common = require('./common')
var assert = require('assert')
var zlib = require('../')
var path = require('path')
@@ -9,7 +8,7 @@ var fs = require('fs')
describe.skip('zlib - flush', function () {
it('works', function (done) {
- var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'))
+ var file = fs.readFileSync(path.join(__dirname, 'fixtures', 'person.jpg'))
var chunkSize = 16
var opts = { level: 0 }
var deflater = zlib.createDeflate(opts)
diff --git a/test/test-zlib-from-concatenated-gzip.js b/test/test-zlib-from-concatenated-gzip.js
index 4969ae9..7007928 100644
--- a/test/test-zlib-from-concatenated-gzip.js
+++ b/test/test-zlib-from-concatenated-gzip.js
@@ -15,7 +15,7 @@ describe.skip('zlib - from concatenated gzip', function () {
assert.equal(zlib.gunzipSync(data).toString(), 'abcdef')
- zlib.gunzip(data, common.mustCall((err, result) => {
+ zlib.gunzip(data, common.mustCall(function (err, result) {
assert.ifError(err)
assert.equal(result, 'abcdef', 'result should match original string')
done()
diff --git a/test/test-zlib-from-gzip-with-trailing-garbage.js b/test/test-zlib-from-gzip-with-trailing-garbage.js
index 7284773..ff2b965 100644
--- a/test/test-zlib-from-gzip-with-trailing-garbage.js
+++ b/test/test-zlib-from-gzip-with-trailing-garbage.js
@@ -16,7 +16,7 @@ describe.skip('zlib - from gzip with trailing garbage', function () {
assert.equal(zlib.gunzipSync(data).toString(), 'abcdef')
- zlib.gunzip(data, common.mustCall((err, result) => {
+ zlib.gunzip(data, common.mustCall(function (err, result) {
assert.ifError(err)
assert.equal(result, 'abcdef', 'result should match original string')
done()
@@ -31,9 +31,11 @@ describe.skip('zlib - from gzip with trailing garbage', function () {
Buffer(10).fill(0)
])
- assert.throws(() => zlib.gunzipSync(data))
+ assert.throws(function () {
+ zlib.gunzipSync(data)
+ })
- zlib.gunzip(data, common.mustCall((err, result) => {
+ zlib.gunzip(data, common.mustCall(function (err, result) {
assert(err)
done()
}))
@@ -48,7 +50,7 @@ describe.skip('zlib - from gzip with trailing garbage', function () {
assert.equal(zlib.gunzipSync(data).toString(), 'abcdef')
- zlib.gunzip(data, common.mustCall((err, result) => {
+ zlib.gunzip(data, common.mustCall(function (err, result) {
assert.ifError(err)
assert.equal(result, 'abcdef', 'result should match original string')
done()
diff --git a/test/test-zlib-params.js b/test/test-zlib-params.js
index 1377da6..953aedd 100644
--- a/test/test-zlib-params.js
+++ b/test/test-zlib-params.js
@@ -1,7 +1,6 @@
/* eslint-env mocha */
'use strict'
-var common = require('./common')
var assert = require('assert')
var zlib = require('../')
var path = require('path')
diff --git a/test/test-zlib-truncated.js b/test/test-zlib-truncated.js
index 2c6cd84..43ba020 100644
--- a/test/test-zlib-truncated.js
+++ b/test/test-zlib-truncated.js
@@ -3,7 +3,7 @@
// tests zlib streams with truncated compressed input
var assert = require('assert')
-var zlib = require('zlib')
+var zlib = require('../')
var inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing el' +
'it. Morbi faucibus, purus at gravida dictum, libero arcu convallis la' +
diff --git a/test/test-zlib.js b/test/test-zlib.js
index 430a17a..56d17e7 100644
--- a/test/test-zlib.js
+++ b/test/test-zlib.js
@@ -1,7 +1,6 @@
/* eslint-env mocha */
'use strict'
-var common = require('./common')
var zlib = require('../')
var path = require('path')
@@ -43,7 +42,7 @@ var fs = require('fs')
var tests = {
'person.jpg': fs.readFileSync(path.join(__dirname, 'fixtures', 'person.jpg')),
'elipses.txt': fs.readFileSync(path.join(__dirname, 'fixtures', 'elipses.txt')),
- // 'empty.txt': fs.readFileSync(path.join(__dirname, 'fixtures', 'empty.txt'))
+ 'empty.txt': new Buffer('')
}
var util = require('util')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-zlib.git
More information about the Pkg-javascript-commits
mailing list