Skip to content

Commit 0016aa2

Browse files
authored
Merge pull request #23 from sfriesel/long-test
Thanks Stefan, good stuff! Check out https://www.npmjs.com/package/tape#terrorerr-msg
2 parents 173d0ef + 18b9eed commit 0016aa2

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"prepare": "mkdir -p dist && browserify -s unbzip2Stream index.js | uglifyjs > dist/unbzip2-stream.min.js",
1616
"browser-test": "browserify -t brfs test/simple.js | tape-run",
17-
"prepare-long-test": "dd if=/dev/urandom of=test/fixtures/vmlinux.bin bs=50x1024x1024 count=2 && cat test/fixtures/vmlinux.bin | bzip2 > test/fixtures/vmlinux.bin.bz2",
17+
"prepare-long-test": "head -c 104857600 < /dev/urandom | tee test/fixtures/vmlinux.bin | bzip2 > test/fixtures/vmlinux.bin.bz2",
1818
"long-test": "tape test/extra/long.js",
1919
"download-test": "beefy test/browser/long.js --open -- -t brfs",
2020
"test": "tape test/*.js"
@@ -38,9 +38,9 @@
3838
"brfs": "^1.2.0",
3939
"browserify": "^8.1.0",
4040
"concat-stream": "^1.4.7",
41+
"stream-equal": "^1.1.1",
4142
"tape": "^3.4.0",
4243
"tape-run": "^4.0.0",
43-
"throughout": "0.0.0",
4444
"uglify-js": "^3.0.10"
4545
},
4646
"dependencies": {

test/extra/long.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
var unbzip2Stream = require('../..');
22
var test = require('tape');
3-
var through = require('through');
4-
var throughout = require('throughout');
53
var fs = require('fs');
4+
var streamEqual = require('stream-equal');
65

76
test('a very large binary file piped into unbzip2-stream results in original file content', function(t) {
8-
t.plan(2);
7+
t.plan(1);
98
var source = fs.createReadStream('test/fixtures/vmlinux.bin.bz2');
9+
var expected = fs.createReadStream('test/fixtures/vmlinux.bin');
1010
var unbz2 = unbzip2Stream();
11-
var received = 0;
12-
var buffers = [];
13-
14-
unbz2.on('error', function(err) {
15-
console.log(err);
16-
//t.notOk(err.message);
11+
source.pipe(unbz2);
12+
streamEqual(expected, unbz2, function(err, equal) {
13+
if (err)
14+
t.ok(false, err);
15+
t.ok(equal, "same file contents");
1716
});
18-
19-
var sink = through( function write(data) {
20-
received += data.length;
21-
buffers.push(data);
22-
}, function end() {
23-
var expected = fs.readFileSync('test/fixtures/vmlinux.bin');
24-
t.equal(received, expected.length);
25-
t.deepEqual(Buffer.concat(buffers), expected);
26-
this.queue(null);
27-
});
28-
source.pipe(throughout(unbz2,sink));
2917
});
30-

0 commit comments

Comments
 (0)