UNPKG

666 BJavaScriptView Raw
1var test = require('tap').test;
2var spawn = require('child_process').spawn;
3var path = require('path');
4var concat = require('concat-stream');
5var vm = require('vm');
6
7test('transform arguments', function (t) {
8 t.plan(2);
9
10 var ps = spawn(process.execPath, [
11 path.resolve(__dirname, '../bin/cmd.js'),
12 __dirname + '/tr_args/main.js',
13 '-t', '[', __dirname + '/tr_args/tr.js', '-x', '1', ']'
14 ]);
15
16 ps.stderr.pipe(process.stderr);
17 ps.stdout.pipe(concat(function (body) {
18 vm.runInNewContext(body.toString('utf8'), { t: t });
19 }));
20
21 ps.on('exit', function (code) {
22 t.equal(code, 0);
23 });
24});