Skip to content

Commit b86dcc9

Browse files
committed
Merge pull request #384 from jamestalmage/hide-annoying-error-printouts
Hide annoying error print outs.
2 parents 1560138 + 6033e9c commit b86dcc9

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

lib/fork.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = function (file, opts) {
1212

1313
var ps = childProcess.fork(path.join(__dirname, 'test-worker.js'), [JSON.stringify(opts)], {
1414
cwd: path.dirname(file),
15-
stdio: ['ignore', process.stderr, process.stderr]
15+
stdio: ['ignore', process.stderr, process.stderr],
16+
silent: opts.silent
1617
});
1718

1819
var relFile = path.relative('.', file);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"devDependencies": {
123123
"coveralls": "^2.11.4",
124124
"delay": "^1.3.0",
125+
"get-stream": "^1.1.0",
125126
"signal-exit": "^2.1.2",
126127
"sinon": "^1.17.2",
127128
"source-map-fixtures": "^0.4.0",

test/cli.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22
var childProcess = require('child_process');
33
var test = require('tap').test;
4+
global.Promise = require('bluebird');
5+
var getStream = require('get-stream');
46

57
function execCli(args, cb) {
68
if (!Array.isArray(args)) {
@@ -13,10 +15,34 @@ function execCli(args, cb) {
1315
env.AVA_APPVEYOR = 1;
1416
}
1517

16-
childProcess.execFile(process.execPath, ['../cli.js'].concat(args), {
17-
cwd: __dirname,
18-
env: env
19-
}, cb);
18+
var stdout;
19+
var stderr;
20+
21+
var processPromise = new Promise(function (resolve) {
22+
var child = childProcess.spawn(process.execPath, ['../cli.js'].concat(args), {
23+
cwd: __dirname,
24+
env: env,
25+
stdio: [null, 'pipe', 'pipe']
26+
});
27+
28+
child.on('close', function (code, signal) {
29+
if (code) {
30+
var err = new Error('test-worker exited with a non-zero exit code: ' + code);
31+
err.code = code;
32+
err.signal = signal;
33+
resolve(err);
34+
return;
35+
}
36+
resolve(code);
37+
});
38+
39+
stdout = getStream(child.stdout);
40+
stderr = getStream(child.stderr);
41+
});
42+
43+
Promise.all([processPromise, stdout, stderr]).then(function (args) {
44+
cb.apply(null, args);
45+
});
2046
}
2147

2248
test('throwing a named function will report the to the console', function (t) {

test/fork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('resolves promise with tests info', function (t) {
3636
test('rejects on error and streams output', function (t) {
3737
t.plan(2);
3838

39-
fork(fixture('broken.js'))
39+
fork(fixture('broken.js'), {silent: true})
4040
.run()
4141
.catch(function (err) {
4242
t.ok(err);

0 commit comments

Comments
 (0)