Skip to content

Commit e722aa9

Browse files
authored
chore: use screen for output in reporters (#37039)
1 parent c7cc661 commit e722aa9

File tree

27 files changed

+198
-118
lines changed

27 files changed

+198
-118
lines changed

eslint.config.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ export default [
339339
message:
340340
"Please use gracefullyProcessExitDoNotHang function to exit the process.",
341341
},
342+
{ object: "process", property: "stdout" },
343+
{ object: "process", property: "stderr" },
342344
],
343345
},
344346
},
@@ -354,13 +356,6 @@ export default [
354356
...noFloatingPromisesRules,
355357
},
356358
},
357-
{
358-
files: ["packages/playwright/src/reporters/**/*.ts"],
359-
languageOptions: languageOptionsWithTsConfig,
360-
rules: {
361-
"no-console": "off",
362-
},
363-
},
364359
{
365360
files: [
366361
"packages/playwright-core/src/utils/**/*.ts",

packages/playwright-core/src/cli/driver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function runDriver() {
3838
const playwright = createPlaywright({ sdkLanguage });
3939
return new PlaywrightDispatcher(rootScope, playwright);
4040
});
41+
// eslint-disable-next-line no-restricted-properties
4142
const transport = new PipeTransport(process.stdout, process.stdin);
4243
transport.onmessage = (message: string) => dispatcherConnection.dispatch(JSON.parse(message));
4344
// Certain Language Binding JSON parsers (e.g. .NET) do not like strings with lone surrogates.

packages/playwright-core/src/cli/program.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,13 @@ async function maybeSetupTestHooks(browser: Browser, closeBrowser: () => Promise
643643
require('playwright-core/lib/utilsBundle').debug.log = (...args: any[]) => {
644644
const line = require('util').format(...args) + '\n';
645645
logs.push(line);
646+
// eslint-disable-next-line no-restricted-properties
646647
process.stderr.write(line);
647648
};
648649
browser.on('disconnected', () => {
649650
const hasCrashLine = logs.some(line => line.includes('process did exit:') && !line.includes('process did exit: exitCode=0, signal=null'));
650651
if (hasCrashLine) {
652+
// eslint-disable-next-line no-restricted-properties
651653
process.stderr.write('Detected browser crash.\n');
652654
gracefullyProcessExitDoNotHang(1);
653655
}

packages/playwright-core/src/outofprocess.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PlaywrightClient {
4747
},
4848
});
4949
this._driverProcess.unref();
50+
// eslint-disable-next-line no-restricted-properties
5051
this._driverProcess.stderr!.on('data', data => process.stderr.write(data));
5152

5253
const connection = new Connection(nodePlatform);

packages/playwright-core/src/server/electron/electron.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export class Electron extends SdkObject {
292292

293293
async function waitForLine(progress: Progress, process: childProcess.ChildProcess, regex: RegExp) {
294294
const promise = new ManualPromise<RegExpMatchArray>();
295+
// eslint-disable-next-line no-restricted-properties
295296
const rl = readline.createInterface({ input: process.stderr! });
296297
const failError = new Error('Process failed to launch!');
297298
const listeners = [

packages/playwright-core/src/server/registry/browserFetcher.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export function logPolitely(toBeLogged: string) {
126126
type OnProgressCallback = (downloadedBytes: number, totalBytes: number) => void;
127127

128128
function getDownloadProgress(): OnProgressCallback {
129+
// eslint-disable-next-line no-restricted-properties
129130
if (process.stdout.isTTY)
130131
return getAnimatedDownloadProgress();
131132
return getBasicDownloadProgress();

packages/playwright-core/src/server/registry/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ export class Registry {
10681068
const { embedderName } = getEmbedderName();
10691069
if (!getAsBooleanFromENV('CI') && !executable._isHermeticInstallation && !forceReinstall && executable.executablePath(embedderName)) {
10701070
const command = buildPlaywrightCLICommand(embedderName, 'install --force ' + executable.name);
1071+
// eslint-disable-next-line no-restricted-properties
10711072
process.stderr.write('\n' + wrapInASCIIBox([
10721073
`ATTENTION: "${executable.name}" is already installed on the system!`,
10731074
``,
@@ -1132,6 +1133,7 @@ export class Registry {
11321133

11331134
async validateHostRequirementsForExecutablesIfNeeded(executables: Executable[], sdkLanguage: string) {
11341135
if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS')) {
1136+
// eslint-disable-next-line no-restricted-properties
11351137
process.stderr.write('Skipping host requirements validation logic because `PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS` env variable is set.\n');
11361138
return;
11371139
}

packages/playwright-core/src/server/trace/viewer/traceViewer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ export async function openTraceViewerApp(url: string, browserName: string, optio
182182
await controller.run(async progress => {
183183
await context._browser._defaultContext!._loadDefaultContextAsIs(progress);
184184

185-
if (process.env.PWTEST_PRINT_WS_ENDPOINT)
185+
if (process.env.PWTEST_PRINT_WS_ENDPOINT) {
186+
// eslint-disable-next-line no-restricted-properties
186187
process.stderr.write('DevTools listening on: ' + context._browser.options.wsEndpoint + '\n');
188+
}
187189

188190
if (!isUnderTest())
189191
await syncLocalStorageWithSettings(page, 'traceviewer');

packages/playwright-core/src/server/utils/spawnAsync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export function spawnAsync(cmd: string, args: string[], options: SpawnOptions =
2424
return new Promise(resolve => {
2525
let stdout = '';
2626
let stderr = '';
27+
/* eslint-disable no-restricted-properties */
2728
if (process.stdout)
2829
process.stdout.on('data', data => stdout += data.toString());
2930
if (process.stderr)
3031
process.stderr.on('data', data => stderr += data.toString());
32+
/* eslint-enable no-restricted-properties */
3133
process.on('close', code => resolve({ stdout, stderr, code }));
3234
process.on('error', error => resolve({ stdout, stderr, code: 0, error }));
3335
});

packages/playwright/src/program.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ async function runTestServer(opts: { [key: string]: any }) {
234234

235235
export async function withRunnerAndMutedWrite(configFile: string | undefined, callback: (runner: Runner) => Promise<any>) {
236236
// Redefine process.stdout.write in case config decides to pollute stdio.
237+
// eslint-disable-next-line no-restricted-properties
237238
const stdoutWrite = process.stdout.write.bind(process.stdout);
239+
// eslint-disable-next-line no-restricted-properties
238240
process.stdout.write = ((a: any, b: any, c: any) => process.stderr.write(a, b, c)) as any;
239241
try {
240242
const config = await loadConfigFromFile(configFile);

0 commit comments

Comments
 (0)