mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-01 08:34:02 +03:00
test: improve debugability of installation tests (#17277)
Put more details into the error message. This way it is immediately seen on the bots.
This commit is contained in:
parent
705bc28e92
commit
68072a5d5c
@ -139,27 +139,30 @@ export const test = _test.extend<{
|
||||
});
|
||||
});
|
||||
|
||||
const stdio = `${result.stdout}\n${result.stderr}`;
|
||||
|
||||
await testInfo.attach(`${[cmd, ...args].join(' ')}`, { body: `COMMAND: ${[cmd, ...args].join(' ')}\n\nEXIT CODE: ${result.code}\n\n====== STDIO + STDERR ======\n\n${stdio}` });
|
||||
const command = [cmd, ...args].join(' ');
|
||||
const stdio = result.stdout + result.stderr;
|
||||
await testInfo.attach(command, { body: `COMMAND: ${command}\n\nEXIT CODE: ${result.code}\n\n====== STDOUT + STDERR ======\n\n${stdio}` });
|
||||
|
||||
// This means something is really off with spawn
|
||||
if (result.error)
|
||||
throw result.error;
|
||||
|
||||
// User expects command to fail
|
||||
if (options.expectToExitWithError) {
|
||||
if (result.code === 0) {
|
||||
const message = options.message ? ` Message: ${options.message}` : '';
|
||||
throw new Error(`Expected the command to exit with an error, but exited cleanly.${message}`);
|
||||
}
|
||||
} else if (result.code !== 0) {
|
||||
const message = options.message ? ` Message: ${options.message}` : '';
|
||||
throw new Error(`Expected the command to exit cleanly (0 status code), but exited with ${result.code}.${message}`);
|
||||
}
|
||||
const error: string[] = [];
|
||||
if (options.expectToExitWithError && result.code === 0)
|
||||
error.push(`Expected the command to exit with an error, but exited cleanly.`);
|
||||
else if (!options.expectToExitWithError && result.code !== 0)
|
||||
error.push(`Expected the command to exit cleanly (0 status code), but exited with ${result.code}.`);
|
||||
|
||||
return stdio;
|
||||
if (!error.length)
|
||||
return stdio;
|
||||
|
||||
if (options.message)
|
||||
error.push(`Message: ${options.message}`);
|
||||
error.push(`Command: ${command}`);
|
||||
error.push(`EXIT CODE: ${result.code}`);
|
||||
error.push(`====== STDIO ======\n${stdio}`);
|
||||
|
||||
throw new Error(error.join('\n'));
|
||||
});
|
||||
},
|
||||
tsc: async ({ exec }, use) => {
|
||||
|
Loading…
Reference in New Issue
Block a user