blob: 41774cb87a989fbf9d89b85bfebc8a08ef15b24f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
'use strict';
require('../common');
const assert = require('assert');
const os = require('os');
switch (process.argv[2]) {
case 'child':
return child();
case undefined:
return parent();
default:
throw new Error('wtf? ' + process.argv[2]);
}
function parent() {
const spawn = require('child_process').spawn;
var child = spawn(process.execPath, [__filename, 'child']);
var output = '';
child.stderr.on('data', function(c) {
output += c;
});
child.stderr.setEncoding('utf8');
child.stderr.on('end', function() {
assert.equal(output, 'I can still debug!' + os.EOL);
console.log('ok - got expected message');
});
child.on('exit', function(c) {
assert(!c);
console.log('ok - child exited nicely');
});
}
function child() {
// even when all hope is lost...
process.nextTick = function() {
throw new Error('No ticking!');
};
var stderr = process.stderr;
stderr.write = function() {
throw new Error('No writing to stderr!');
};
process._rawDebug('I can still %s!', 'debug');
}
|