mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
Revert "test: make debugp collect IO (#1485)"
This reverts commit b1bebdad2e22daf2a49a24d2134905650d8e264c.
This commit is contained in:
parent
b1bebdad2e
commit
1ddf05113b
@ -44,7 +44,6 @@ export class CRConnection extends platform.EventEmitter {
|
|||||||
this.rootSession = new CRSession(this, '', 'browser', '');
|
this.rootSession = new CRSession(this, '', 'browser', '');
|
||||||
this._sessions.set('', this.rootSession);
|
this._sessions.set('', this.rootSession);
|
||||||
this._debugProtocol = platform.debug('pw:protocol');
|
this._debugProtocol = platform.debug('pw:protocol');
|
||||||
(this._debugProtocol as any).color = '34';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromSession(session: CRSession): CRConnection {
|
static fromSession(session: CRSession): CRConnection {
|
||||||
|
@ -58,7 +58,6 @@ export class FFConnection extends platform.EventEmitter {
|
|||||||
this.off = super.removeListener;
|
this.off = super.removeListener;
|
||||||
this.removeListener = super.removeListener;
|
this.removeListener = super.removeListener;
|
||||||
this.once = super.once;
|
this.once = super.once;
|
||||||
(this._debugProtocol as any).color = '34';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async send<T extends keyof Protocol.CommandParameters>(
|
async send<T extends keyof Protocol.CommandParameters>(
|
||||||
|
@ -24,10 +24,6 @@ import { TimeoutError } from '../errors';
|
|||||||
import * as platform from '../platform';
|
import * as platform from '../platform';
|
||||||
|
|
||||||
const debugLauncher = platform.debug('pw:launcher');
|
const debugLauncher = platform.debug('pw:launcher');
|
||||||
const debugStdout = platform.debug('pw:stdio:out');
|
|
||||||
const debugStderr = platform.debug('pw:stdio:err');
|
|
||||||
(debugStdout as any).color = '178';
|
|
||||||
(debugStderr as any).color = '160';
|
|
||||||
const removeFolderAsync = platform.promisify(removeFolder);
|
const removeFolderAsync = platform.promisify(removeFolder);
|
||||||
|
|
||||||
export type LaunchProcessOptions = {
|
export type LaunchProcessOptions = {
|
||||||
@ -77,19 +73,13 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stdout = readline.createInterface({ input: spawnedProcess.stdout });
|
if (options.dumpio) {
|
||||||
stdout.on('line', (data: string) => {
|
spawnedProcess.stdout.pipe(process.stdout);
|
||||||
debugStdout(data);
|
spawnedProcess.stderr.pipe(process.stderr);
|
||||||
if (options.dumpio)
|
} else {
|
||||||
console.log(`\x1b[33m[out]\x1b[0m ${data}`); // eslint-disable-line no-console
|
spawnedProcess.stderr.on('data', () => {});
|
||||||
});
|
spawnedProcess.stdout.on('data', () => {});
|
||||||
|
}
|
||||||
const stderr = readline.createInterface({ input: spawnedProcess.stderr });
|
|
||||||
stderr.on('line', (data: string) => {
|
|
||||||
debugStderr(data);
|
|
||||||
if (options.dumpio)
|
|
||||||
console.log(`\x1b[31m[err]\x1b[0m ${data}`); // eslint-disable-line no-console
|
|
||||||
});
|
|
||||||
|
|
||||||
let processClosed = false;
|
let processClosed = false;
|
||||||
const waitForProcessToClose = new Promise((fulfill, reject) => {
|
const waitForProcessToClose = new Promise((fulfill, reject) => {
|
||||||
|
@ -46,7 +46,6 @@ export class WKConnection {
|
|||||||
this.browserSession = new WKSession(this, '', 'Browser has been closed.', (message: any) => {
|
this.browserSession = new WKSession(this, '', 'Browser has been closed.', (message: any) => {
|
||||||
this.rawSend(message);
|
this.rawSend(message);
|
||||||
});
|
});
|
||||||
(this._debugFunction as any).color = '34';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextMessageId(): number {
|
nextMessageId(): number {
|
||||||
|
@ -72,14 +72,14 @@ module.exports.describe = function({testRunner, expect, product, browserType, pl
|
|||||||
it.slow()('should dump browser process stderr', async({server}) => {
|
it.slow()('should dump browser process stderr', async({server}) => {
|
||||||
let dumpioData = '';
|
let dumpioData = '';
|
||||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product, 'usewebsocket']);
|
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product, 'usewebsocket']);
|
||||||
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
|
res.stderr.on('data', data => dumpioData += data.toString('utf8'));
|
||||||
await new Promise(resolve => res.on('close', resolve));
|
await new Promise(resolve => res.on('close', resolve));
|
||||||
expect(dumpioData).toContain('message from dumpio');
|
expect(dumpioData).toContain('message from dumpio');
|
||||||
});
|
});
|
||||||
it.slow()('should dump browser process stderr', async({server}) => {
|
it.slow()('should dump browser process stderr', async({server}) => {
|
||||||
let dumpioData = '';
|
let dumpioData = '';
|
||||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product]);
|
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product]);
|
||||||
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
|
res.stderr.on('data', data => dumpioData += data.toString('utf8'));
|
||||||
await new Promise(resolve => res.on('close', resolve));
|
await new Promise(resolve => res.on('close', resolve));
|
||||||
expect(dumpioData).toContain('message from dumpio');
|
expect(dumpioData).toContain('message from dumpio');
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,6 @@ const os = require('os');
|
|||||||
const rm = require('rimraf').sync;
|
const rm = require('rimraf').sync;
|
||||||
const GoldenUtils = require('./golden-utils');
|
const GoldenUtils = require('./golden-utils');
|
||||||
const {Matchers} = require('../utils/testrunner/');
|
const {Matchers} = require('../utils/testrunner/');
|
||||||
const readline = require('readline');
|
|
||||||
|
|
||||||
const YELLOW_COLOR = '\x1b[33m';
|
const YELLOW_COLOR = '\x1b[33m';
|
||||||
const RESET_COLOR = '\x1b[0m';
|
const RESET_COLOR = '\x1b[0m';
|
||||||
@ -104,8 +103,6 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => {
|
|||||||
beforeAll(async state => {
|
beforeAll(async state => {
|
||||||
state.browser = await browserType.launch(defaultBrowserOptions);
|
state.browser = await browserType.launch(defaultBrowserOptions);
|
||||||
state.browserServer = state.browser.__server__;
|
state.browserServer = state.browser.__server__;
|
||||||
state._stdout = readline.createInterface({ input: state.browserServer.process().stdout });
|
|
||||||
state._stderr = readline.createInterface({ input: state.browserServer.process().stderr });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async state => {
|
afterAll(async state => {
|
||||||
@ -115,18 +112,22 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(state, test) => {
|
beforeEach(async(state, test) => {
|
||||||
test.output = [];
|
const onLine = (line) => test.output += line + '\n';
|
||||||
const dumpout = data => test.output.push(`\x1b[33m[pw:stdio:out]\x1b[0m ${data}`);
|
|
||||||
const dumperr = data => test.output.push(`\x1b[31m[pw:stdio:err]\x1b[0m ${data}`);
|
|
||||||
state._stdout.on('line', dumpout);
|
|
||||||
state._stderr.on('line', dumperr);
|
|
||||||
if (dumpProtocolOnFailure)
|
if (dumpProtocolOnFailure)
|
||||||
state.browser._setDebugFunction(data => test.output.push(`\x1b[32m[pw:protocol]\x1b[0m ${data}`));
|
state.browser._setDebugFunction(onLine);
|
||||||
|
|
||||||
|
let rl;
|
||||||
|
if (state.browserServer.process().stderr) {
|
||||||
|
rl = require('readline').createInterface({ input: state.browserServer.process().stderr });
|
||||||
|
test.output = '';
|
||||||
|
rl.on('line', onLine);
|
||||||
|
}
|
||||||
|
|
||||||
state.tearDown = async () => {
|
state.tearDown = async () => {
|
||||||
state._stdout.off('line', dumpout);
|
if (rl) {
|
||||||
state._stderr.off('line', dumperr);
|
rl.removeListener('line', onLine);
|
||||||
state._stdout.close();
|
rl.close();
|
||||||
state._stderr.close();
|
}
|
||||||
if (dumpProtocolOnFailure)
|
if (dumpProtocolOnFailure)
|
||||||
state.browser._setDebugFunction(() => void 0);
|
state.browser._setDebugFunction(() => void 0);
|
||||||
};
|
};
|
||||||
|
@ -207,8 +207,7 @@ class Reporter {
|
|||||||
console.log(`${prefix} ${colors.red(`[TIMEOUT ${test.timeout}ms]`)} ${test.fullName} (${formatLocation(test.location)})`);
|
console.log(`${prefix} ${colors.red(`[TIMEOUT ${test.timeout}ms]`)} ${test.fullName} (${formatLocation(test.location)})`);
|
||||||
if (test.output) {
|
if (test.output) {
|
||||||
console.log(' Output:');
|
console.log(' Output:');
|
||||||
for (const line of test.output)
|
console.log(padLines(test.output, 4));
|
||||||
console.log(' ' + line);
|
|
||||||
}
|
}
|
||||||
} else if (test.result === 'failed') {
|
} else if (test.result === 'failed') {
|
||||||
console.log(`${prefix} ${colors.red('[FAIL]')} ${test.fullName} (${formatLocation(test.location)})`);
|
console.log(`${prefix} ${colors.red('[FAIL]')} ${test.fullName} (${formatLocation(test.location)})`);
|
||||||
@ -254,8 +253,7 @@ class Reporter {
|
|||||||
}
|
}
|
||||||
if (test.output) {
|
if (test.output) {
|
||||||
console.log(' Output:');
|
console.log(' Output:');
|
||||||
for (const line of test.output)
|
console.log(padLines(test.output, 4));
|
||||||
console.log(' ' + line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user