Skip to content
Browse files

upgrade the tests for the latest concat-stream

  • Loading branch information...
1 parent a7f535b commit a303ab8f70a2f7dd6aceeb7a43fd7e17acc87285 @substack committed Nov 18, 2013
Showing with 54 additions and 53 deletions.
  1. +1 −0 index.js
  2. +1 −1 lib/builtins/cd.js
  3. +2 −2 package.json
  4. +13 −13 test/andor.js
  5. +2 −2 test/cd.js
  6. +4 −4 test/env.js
  7. +4 −4 test/exit.js
  8. +2 −2 test/pipe.js
  9. +6 −6 test/read.js
  10. +2 −2 test/run.js
  11. +2 −2 test/semicolon.js
  12. +15 −15 test/write.js
View
1 index.js
@@ -305,6 +305,7 @@ Bash.prototype.createStream = function () {
output.queue(msg + '\n');
p.emit('exit', code);
}
+ else p.emit('exit', code);
};
}
View
2 lib/builtins/cd.js
@@ -8,7 +8,7 @@ module.exports = function (args) {
var dir = env.HOME;
var argv = parseArgs(args);
- var dir = argv._[0] === undefined ? env.HOME : argv._[0];
+ var dir = (argv._[0] === undefined ? env.HOME : argv._[0]) || '';
var edir = dir.replace(/^~\//, function () { return env.HOME + '/' });
edir = path.resolve(env.PWD, edir);
View
4 package.json
@@ -13,8 +13,8 @@
"inherits": "~1.0.0"
},
"devDependencies": {
- "tap": "~0.4.0",
- "concat-stream": "~0.1.1",
+ "tap": "~0.4.4",
+ "concat-stream": "~1.2.0",
"mkdirp": "~0.3.5"
},
"scripts": {
View
26 test/andor.js
@@ -16,8 +16,8 @@ test('true and', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ TRUE\nabcdefg\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ TRUE\nabcdefg\n');
}));
s.end('true && echo $XYZ\n');
});
@@ -32,8 +32,8 @@ test('false and', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ FALSE\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ FALSE\n');
}));
s.end('false && echo $XYZ\n');
});
@@ -48,8 +48,8 @@ test('false or', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ FALSE\nabcdefg\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ FALSE\nabcdefg\n');
}));
s.end('false || echo $XYZ\n');
});
@@ -64,8 +64,8 @@ test('true or', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ TRUE\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ TRUE\n');
}));
s.end('true || echo $XYZ\n');
});
@@ -80,7 +80,7 @@ test('false and true or', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(src, '$ FALSE\nabcdefg\n');
}));
s.end('false && true || echo $XYZ\n');
@@ -96,8 +96,8 @@ test('false or true and', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ FALSE\nTRUE\nabcdefg\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ FALSE\nTRUE\nabcdefg\n');
}));
s.end('false || true && echo $XYZ\n');
});
@@ -112,8 +112,8 @@ test('false or false and', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ FALSE\nFALSE\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ FALSE\nFALSE\n');
}));
s.end('false || false && echo $XYZ\n');
});
View
4 test/cd.js
@@ -20,8 +20,8 @@ test('basic cd', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 0\n/home/robot\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 0\n/home/robot\n');
}));
s.end('cd; echo $?; pwd');
});
View
8 test/env.js
@@ -9,8 +9,8 @@ test('set env vars', function (t) {
var sh = bash({ spawn: run, env: { X: 3, PS1: '$ ' } });
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 3\n5\n3\n2\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 3\n5\n3\n2\n');
}));
s.write('printx; X=5 printx; printx; X=2; printx\n');
s.end();
@@ -22,8 +22,8 @@ test('set quoted env var', function (t) {
var sh = bash({ spawn: run, env: { X: 3, PS1: '$ ' } });
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 7 8 9\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 7 8 9\n');
}));
s.write('X="7 8 9"; printx\n');
s.end();
View
8 test/exit.js
@@ -17,7 +17,7 @@ test('true $?', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(env['?'], 0);
}));
s.end('true\n');
@@ -34,7 +34,7 @@ test('false $?', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(env['?'], 1);
}));
s.end('false\n');
@@ -51,7 +51,7 @@ test('true; echo $?', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(src, '$ 0\n');
}));
s.end('true; echo $?\n');
@@ -68,7 +68,7 @@ test('false; echo $?', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(src, '$ 1\n');
}));
s.end('false; echo $?\n');
View
4 test/pipe.js
@@ -9,8 +9,8 @@ test('run', function (t) {
var sh = bash({ spawn: run, env: { 'PS1': '$ ' } });
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 10\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 10\n');
}));
s.write('echo beep boop | wc -c\n');
s.end();
View
12 test/read.js
@@ -26,8 +26,8 @@ test('wc -c < file', function (t) {
fs.writeFileSync(tempfile, 'beep boop\n');
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 10\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 10\n');
}));
s.write('wc -c < ' + tempfile + '\n');
s.end();
@@ -44,8 +44,8 @@ test('wc -c < relative_file', function (t) {
fs.writeFileSync(tempfile, 'beep boop\n');
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 10\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 10\n');
}));
s.write('wc -c < ' + path.basename(tempfile) + '\n');
s.end();
@@ -62,8 +62,8 @@ test('cat < file | wc -c', function (t) {
fs.writeFileSync(tempfile, 'beep boop\n');
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ 10\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ 10\n');
}));
s.write('cat < ' + tempfile + '| wc -c\n');
s.end();
View
4 test/run.js
@@ -12,8 +12,8 @@ test('run', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, '$ /home/test\nboop\nabcdefg\n');
+ s.pipe(concat(function (src) {
+ t.equal(src + '', '$ /home/test\nboop\nabcdefg\n');
}));
s.write('pwd\n');
s.write('beep\n');
View
4 test/semicolon.js
@@ -16,8 +16,8 @@ test('run', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
- t.equal(src, [
+ s.pipe(concat(function (src) {
+ t.equal(src + '', [
'$ /home/test',
'boop',
'abcdefg',
View
30 test/write.js
@@ -31,12 +31,12 @@ test('echo > file', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(
fs.readFileSync(tempfile, 'utf8'),
'beep boop\n'
);
- t.equal(src, 'beep boop\n');
+ t.equal(src + '', 'beep boop\n');
}));
s.write('echo beep boop > ' + tempfile + '\n');
s.write('cat ' + tempfile + '\n');
@@ -54,7 +54,7 @@ test('echo | wc -c > file', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(
fs.readFileSync(tempfile, 'utf8'),
'10\n'
@@ -75,12 +75,12 @@ test('pwd; echo | wc -c > file', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(
fs.readFileSync(tempfile, 'utf8'),
'10\n'
);
- t.equal(src, tempdir + '\n10\n');
+ t.equal(src + '', tempdir + '\n10\n');
}));
s.write('pwd; echo beep boop | wc -c > ' + path.basename(tempfile) + '\n');
s.write('cat ' + path.basename(tempfile) + '\n');
@@ -98,12 +98,12 @@ test('echo | wc -c > file; pwd', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(
fs.readFileSync(tempfile, 'utf8'),
'10\n'
);
- t.equal(src, path.dirname(tempfile) + '\n10\n');
+ t.equal(src + '', path.dirname(tempfile) + '\n10\n');
}));
s.write('echo beep boop | wc -c > ' + path.basename(tempfile) + '; pwd\n');
s.write('cat ' + path.basename(tempfile) + '\n');
@@ -121,9 +121,9 @@ test('true > file && echo PASS', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(fs.readFileSync(tempfile, 'utf8'), '');
- t.equal(src, '$ PASS\n');
+ t.equal(src + '', '$ PASS\n');
}));
s.write('true > ' + tempfile + ' && echo PASS\n');
s.end();
@@ -140,9 +140,9 @@ test('false > file && echo PASS', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(fs.readFileSync(tempfile, 'utf8'), '');
- t.equal(src, '$ ');
+ t.equal(src + '', '$ ');
}));
s.write('false > ' + tempfile + ' && echo PASS\n');
s.end();
@@ -159,9 +159,9 @@ test('true > file || echo PASS', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(fs.readFileSync(tempfile, 'utf8'), '');
- t.equal(src, '$ ');
+ t.equal(src + '', '$ ');
}));
s.write('true > ' + tempfile + ' || echo PASS\n');
s.end();
@@ -178,9 +178,9 @@ test('false > file || echo PASS', function (t) {
});
var s = sh.createStream();
- s.pipe(concat(function (err, src) {
+ s.pipe(concat(function (src) {
t.equal(fs.readFileSync(tempfile, 'utf8'), '');
- t.equal(src, '$ PASS\n');
+ t.equal(src + '', '$ PASS\n');
}));
s.write('false > ' + tempfile + ' || echo PASS\n');
s.end();

0 comments on commit a303ab8

Please sign in to comment.
Something went wrong with that request. Please try again.