test: make sure browser crashes in CLI tests are marked as such (#15821)
This commit is contained in:
parent
f954891491
commit
ba3c8ffa5c
|
|
@ -410,6 +410,23 @@ async function launchContext(options: Options, headless: boolean, executablePath
|
|||
|
||||
const browser = await browserType.launch(launchOptions);
|
||||
|
||||
if (process.env.PWTEST_CLI_EXIT) {
|
||||
const logs: string[] = [];
|
||||
require('playwright-core/lib/utilsBundle').debug.log = (...args: any[]) => {
|
||||
const line = require('util').format(...args) + '\n';
|
||||
logs.push(line);
|
||||
process.stderr.write(line);
|
||||
};
|
||||
browser.on('disconnected', () => {
|
||||
const hasCrashLine = logs.some(line => line.includes('process did exit:') && !line.includes('process did exit: exitCode=0, signal=null'));
|
||||
if (hasCrashLine) {
|
||||
process.stderr.write('Detected browser crash.\n');
|
||||
// Make sure we exit abnormally when browser crashes.
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Viewport size
|
||||
if (options.viewportSize) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const test = contextTest.extend<CLITestArgs>({
|
|||
return cli;
|
||||
});
|
||||
if (cli)
|
||||
await cli.exited;
|
||||
await cli.exited.catch(() => {});
|
||||
},
|
||||
|
||||
openRecorder: async ({ page, recorderPageGetter }, run) => {
|
||||
|
|
@ -199,6 +199,7 @@ class CLIMock {
|
|||
PWTEST_CLI_EXIT: '1',
|
||||
PWTEST_CLI_HEADLESS: headless ? '1' : undefined,
|
||||
PWTEST_CLI_EXECUTABLE_PATH: executablePath,
|
||||
DEBUG: (process.env.DEBUG ?? '') + ',pw:browser*',
|
||||
},
|
||||
});
|
||||
this.process.onOutput = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue