mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
test: deliver colorful debug messages, do not pipe stdio (#3477)
This commit is contained in:
parent
ae4280a12b
commit
d537088af8
@ -184,9 +184,11 @@ class Worker extends EventEmitter {
|
||||
detached: false,
|
||||
env: {
|
||||
FORCE_COLOR: process.stdout.isTTY ? 1 : 0,
|
||||
DEBUG_COLORS: process.stdout.isTTY ? 1 : 0,
|
||||
...process.env
|
||||
},
|
||||
stdio: ['ignore', 'pipe', 'pipe', 'ipc']
|
||||
// Can't pipe since piping slows down termination for some reason.
|
||||
stdio: ['ignore', 'ignore', 'ignore', 'ipc']
|
||||
});
|
||||
this.process.on('exit', () => this.emit('exit'));
|
||||
this.process.on('message', message => {
|
||||
@ -195,18 +197,23 @@ class Worker extends EventEmitter {
|
||||
});
|
||||
this.stdout = [];
|
||||
this.stderr = [];
|
||||
this.process.stdout.on('data', data => {
|
||||
this.on('stdout', data => {
|
||||
if (runner._options.dumpio)
|
||||
process.stdout.write(data);
|
||||
else
|
||||
this.stdout.push(data.toString());
|
||||
this.stdout.push(data);
|
||||
});
|
||||
|
||||
this.process.stderr.on('data', data => {
|
||||
this.on('stderr', data => {
|
||||
if (runner._options.dumpio)
|
||||
process.stderr.write(data);
|
||||
else
|
||||
this.stderr.push(data.toString());
|
||||
this.stderr.push(data);
|
||||
});
|
||||
this.on('debug', data => {
|
||||
if (runner._options.dumpio)
|
||||
process.stderr.write(data + '\n');
|
||||
else
|
||||
this.stderr.push(data + '\n');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const debug = require('debug');
|
||||
const Mocha = require('mocha');
|
||||
const { fixturesUI, fixturePool } = require('./fixturesUI');
|
||||
const { gracefullyCloseAll } = require('../../lib/server/processLauncher');
|
||||
@ -29,6 +29,18 @@ extendExpects();
|
||||
|
||||
let closed = false;
|
||||
|
||||
process.stdout.write = chunk => {
|
||||
sendMessageToParent('stdout', chunk);
|
||||
};
|
||||
|
||||
process.stderr.write = chunk => {
|
||||
sendMessageToParent('stderr', chunk);
|
||||
};
|
||||
|
||||
debug.log = data => {
|
||||
sendMessageToParent('debug', data);
|
||||
};
|
||||
|
||||
process.on('message', async message => {
|
||||
if (message.method === 'init')
|
||||
process.env.JEST_WORKER_ID = message.params.workerId;
|
||||
|
Loading…
Reference in New Issue
Block a user