Skip to content

Commit 1ddf051

Browse files
committed
Revert "test: make debugp collect IO (#1485)"
This reverts commit b1bebda.
1 parent b1bebda commit 1ddf051

File tree

7 files changed

+25
-39
lines changed

7 files changed

+25
-39
lines changed

src/chromium/crConnection.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export class CRConnection extends platform.EventEmitter {
4444
this.rootSession = new CRSession(this, '', 'browser', '');
4545
this._sessions.set('', this.rootSession);
4646
this._debugProtocol = platform.debug('pw:protocol');
47-
(this._debugProtocol as any).color = '34';
4847
}
4948

5049
static fromSession(session: CRSession): CRConnection {

src/firefox/ffConnection.ts

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class FFConnection extends platform.EventEmitter {
5858
this.off = super.removeListener;
5959
this.removeListener = super.removeListener;
6060
this.once = super.once;
61-
(this._debugProtocol as any).color = '34';
6261
}
6362

6463
async send<T extends keyof Protocol.CommandParameters>(

src/server/processLauncher.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ import { TimeoutError } from '../errors';
2424
import * as platform from '../platform';
2525

2626
const debugLauncher = platform.debug('pw:launcher');
27-
const debugStdout = platform.debug('pw:stdio:out');
28-
const debugStderr = platform.debug('pw:stdio:err');
29-
(debugStdout as any).color = '178';
30-
(debugStderr as any).color = '160';
3127
const removeFolderAsync = platform.promisify(removeFolder);
3228

3329
export type LaunchProcessOptions = {
@@ -77,19 +73,13 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
7773
return result;
7874
}
7975

80-
const stdout = readline.createInterface({ input: spawnedProcess.stdout });
81-
stdout.on('line', (data: string) => {
82-
debugStdout(data);
83-
if (options.dumpio)
84-
console.log(`\x1b[33m[out]\x1b[0m ${data}`); // eslint-disable-line no-console
85-
});
86-
87-
const stderr = readline.createInterface({ input: spawnedProcess.stderr });
88-
stderr.on('line', (data: string) => {
89-
debugStderr(data);
90-
if (options.dumpio)
91-
console.log(`\x1b[31m[err]\x1b[0m ${data}`); // eslint-disable-line no-console
92-
});
76+
if (options.dumpio) {
77+
spawnedProcess.stdout.pipe(process.stdout);
78+
spawnedProcess.stderr.pipe(process.stderr);
79+
} else {
80+
spawnedProcess.stderr.on('data', () => {});
81+
spawnedProcess.stdout.on('data', () => {});
82+
}
9383

9484
let processClosed = false;
9585
const waitForProcessToClose = new Promise((fulfill, reject) => {

src/webkit/wkConnection.ts

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export class WKConnection {
4646
this.browserSession = new WKSession(this, '', 'Browser has been closed.', (message: any) => {
4747
this.rawSend(message);
4848
});
49-
(this._debugFunction as any).color = '34';
5049
}
5150

5251
nextMessageId(): number {

test/fixtures.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ module.exports.describe = function({testRunner, expect, product, browserType, pl
7272
it.slow()('should dump browser process stderr', async({server}) => {
7373
let dumpioData = '';
7474
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product, 'usewebsocket']);
75-
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
75+
res.stderr.on('data', data => dumpioData += data.toString('utf8'));
7676
await new Promise(resolve => res.on('close', resolve));
7777
expect(dumpioData).toContain('message from dumpio');
7878
});
7979
it.slow()('should dump browser process stderr', async({server}) => {
8080
let dumpioData = '';
8181
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, product]);
82-
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
82+
res.stderr.on('data', data => dumpioData += data.toString('utf8'));
8383
await new Promise(resolve => res.on('close', resolve));
8484
expect(dumpioData).toContain('message from dumpio');
8585
});

test/playwright.spec.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const os = require('os');
2020
const rm = require('rimraf').sync;
2121
const GoldenUtils = require('./golden-utils');
2222
const {Matchers} = require('../utils/testrunner/');
23-
const readline = require('readline');
2423

2524
const YELLOW_COLOR = '\x1b[33m';
2625
const RESET_COLOR = '\x1b[0m';
@@ -104,8 +103,6 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => {
104103
beforeAll(async state => {
105104
state.browser = await browserType.launch(defaultBrowserOptions);
106105
state.browserServer = state.browser.__server__;
107-
state._stdout = readline.createInterface({ input: state.browserServer.process().stdout });
108-
state._stderr = readline.createInterface({ input: state.browserServer.process().stderr });
109106
});
110107

111108
afterAll(async state => {
@@ -115,18 +112,22 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => {
115112
});
116113

117114
beforeEach(async(state, test) => {
118-
test.output = [];
119-
const dumpout = data => test.output.push(`\x1b[33m[pw:stdio:out]\x1b[0m ${data}`);
120-
const dumperr = data => test.output.push(`\x1b[31m[pw:stdio:err]\x1b[0m ${data}`);
121-
state._stdout.on('line', dumpout);
122-
state._stderr.on('line', dumperr);
115+
const onLine = (line) => test.output += line + '\n';
123116
if (dumpProtocolOnFailure)
124-
state.browser._setDebugFunction(data => test.output.push(`\x1b[32m[pw:protocol]\x1b[0m ${data}`));
117+
state.browser._setDebugFunction(onLine);
118+
119+
let rl;
120+
if (state.browserServer.process().stderr) {
121+
rl = require('readline').createInterface({ input: state.browserServer.process().stderr });
122+
test.output = '';
123+
rl.on('line', onLine);
124+
}
125+
125126
state.tearDown = async () => {
126-
state._stdout.off('line', dumpout);
127-
state._stderr.off('line', dumperr);
128-
state._stdout.close();
129-
state._stderr.close();
127+
if (rl) {
128+
rl.removeListener('line', onLine);
129+
rl.close();
130+
}
130131
if (dumpProtocolOnFailure)
131132
state.browser._setDebugFunction(() => void 0);
132133
};

utils/testrunner/Reporter.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ class Reporter {
207207
console.log(`${prefix} ${colors.red(`[TIMEOUT ${test.timeout}ms]`)} ${test.fullName} (${formatLocation(test.location)})`);
208208
if (test.output) {
209209
console.log(' Output:');
210-
for (const line of test.output)
211-
console.log(' ' + line);
210+
console.log(padLines(test.output, 4));
212211
}
213212
} else if (test.result === 'failed') {
214213
console.log(`${prefix} ${colors.red('[FAIL]')} ${test.fullName} (${formatLocation(test.location)})`);
@@ -254,8 +253,7 @@ class Reporter {
254253
}
255254
if (test.output) {
256255
console.log(' Output:');
257-
for (const line of test.output)
258-
console.log(' ' + line);
256+
console.log(padLines(test.output, 4));
259257
}
260258
}
261259
}

0 commit comments

Comments
 (0)