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}`;
|
const command = [cmd, ...args].join(' ');
|
||||||
|
const stdio = result.stdout + 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}` });
|
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
|
// This means something is really off with spawn
|
||||||
if (result.error)
|
if (result.error)
|
||||||
throw result.error;
|
throw result.error;
|
||||||
|
|
||||||
// User expects command to fail
|
const error: string[] = [];
|
||||||
if (options.expectToExitWithError) {
|
if (options.expectToExitWithError && result.code === 0)
|
||||||
if (result.code === 0) {
|
error.push(`Expected the command to exit with an error, but exited cleanly.`);
|
||||||
const message = options.message ? ` Message: ${options.message}` : '';
|
else if (!options.expectToExitWithError && result.code !== 0)
|
||||||
throw new Error(`Expected the command to exit with an error, but exited cleanly.${message}`);
|
error.push(`Expected the command to exit cleanly (0 status code), but exited with ${result.code}.`);
|
||||||
}
|
|
||||||
} 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}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
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) => {
|
tsc: async ({ exec }, use) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue