var tap = require('tap') var read = require('../lib/read.js') if (process.argv[2] === 'child') { return child() } var CLOSE = 'close' if (process.version.match(/^v0\.6/)) { CLOSE = 'exit' } var spawn = require('child_process').spawn tap.test('basic', function (t) { var child = spawn(process.execPath, [__filename, 'child']) var output = '' var write = child.stdin.write.bind(child.stdin) child.stdout.on('data', function (c) { console.error('data %s', c) output += c if (output.match(/Username: \(test-user\) $/)) { process.nextTick(write.bind(null, 'a user\n')) } else if (output.match(/Password: \(