Skip to content

Commit

Permalink
Consolidate CI test output into a single string (#8489)
Browse files Browse the repository at this point in the history
* Consolidate CI test output into a single string

Having CI test process stdout and stderr in a single string makes it
easier to read when looking through failures, since you can see the test
output alongside the error messages.

Without this, any stderr output written during a test will be captured
seperately from the test output, so when we then log it after a test
failure, we can't tell which test logged which errors.

* Prefix stdout and stderr output
  • Loading branch information
dlarocque authored Nov 6, 2024
1 parent 274e9a5 commit e3e2078
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions scripts/run_tests_in_ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const argv = yargs.options({
const dir = path.resolve(myPath);
const { name } = require(`${dir}/package.json`);

let stdout = '';
let stderr = '';
let testProcessOutput = '';
try {
if (process.env?.BROWSERS) {
for (const package in crossBrowserPackages) {
Expand All @@ -74,27 +73,26 @@ const argv = yargs.options({
const testProcess = spawn('yarn', ['--cwd', dir, scriptName]);

testProcess.childProcess.stdout.on('data', data => {
stdout += data.toString();
testProcessOutput += '[stdout]' + data.toString();
});
testProcess.childProcess.stderr.on('data', data => {
stderr += data.toString();
testProcessOutput += '[stderr]' + data.toString();
});

await testProcess;
console.log('Success: ' + name);
writeLogs('Success', name, stdout + '\n' + stderr);
writeLogs('Success', name, testProcessOutput);
} catch (e) {
console.error('Failure: ' + name);
console.log(stdout);
console.error(stderr);
console.error(testProcessOutput);

if (process.env.CHROME_VERSION_NOTES) {
console.error();
console.error(process.env.CHROME_VERSION_NOTES);
console.error();
}

writeLogs('Failure', name, stdout + '\n' + stderr);
writeLogs('Failure', name, testProcessOutput);

process.exit(1);
}
Expand Down

0 comments on commit e3e2078

Please sign in to comment.