UNPKG

854 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('glob', function (t) {
8 var expected = [ 'a', '!x', 'z', 'b', '!y' ];
9 t.plan(expected.length + 1);
10
11 var cwd = process.cwd();
12 process.chdir(__dirname);
13
14 var ps = spawn(process.execPath, [
15 path.resolve(__dirname, '../bin/cmd.js'),
16 'a.js', 'b.js',
17 '-u', 'vendor/*.js'
18 ], { cwd: __dirname + '/glob' });
19 ps.stderr.pipe(process.stderr);
20 ps.stdout.pipe(concat(function (body) {
21 var c = { console: { log: log } };
22 vm.runInNewContext(body.toString('utf8'), c);
23 function log (msg) { t.equal(msg, expected.shift()) }
24 }));
25
26 ps.on('exit', function (code) {
27 t.equal(code, 0);
28 });
29});