tr_args.js 666 B

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