Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created April 18, 2014 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafintosh/11063733 to your computer and use it in GitHub Desktop.
Save mafintosh/11063733 to your computer and use it in GitHub Desktop.
Single file test case for nodejs/node-v0.x-archive#7481
var proc = require('child_process');
if (process.argv[2] === 'test') {
var stdin = process.stdin; // this line breaks things
var buf = new Buffer(512);
var cnt = 0;
buf.fill(97);
process.stdout.on('error', function(err) {
console.error('onerror', err.message);
process.exit(1)
});
setInterval(function() {
console.log(buf.toString()+' #'+(cnt++)+'\n');
}, 5);
} else {
proc.spawn('/bin/sh', ['-c', 'node '+__filename+ ' test | cat -'], {stdio: 'inherit'});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment