function testCmd(t,n){return function(e){var s=setTimeout(function(){assert.fail("Never got stdout data.")},5e3),r=process.cwd();process.chdir(__dirname+"/_");var o=t.split(" "),d=spawn(o[0],o.slice(1).concat(n.map(String)));process.chdir(r);d.stderr.on("data",function(t){e.error(t);e.end()});d.stdout.on("data",function(t){clearTimeout(s);var r=JSON.parse(t.toString());e.same(r.map(String),n.map(String));e.end()})}}var spawn=require("child_process").spawn,test=require("tap").test;test("dotSlashEmpty",testCmd("./bin.js",[]));test("dotSlashArgs",testCmd("./bin.js",["a","b","c"]));test("nodeEmpty",testCmd("node bin.js",[]));test("nodeArgs",testCmd("node bin.js",["x","y","z"]));test("whichNodeEmpty",function(t){var n=spawn("which",["node"]);n.stdout.on("data",function(n){t.test(testCmd(n.toString().trim()+" bin.js",[]));t.end()});n.stderr.on("data",function(n){assert.error(n);t.end()})});test("whichNodeArgs",function(t){var n=spawn("which",["node"]);n.stdout.on("data",function(n){t.test(testCmd(n.toString().trim()+" bin.js",["q","r"]));t.end()});n.stderr.on("data",function(n){t.error(n);t.end()})});