Skip to content

Commit

Permalink
Consolidate CI test output into a single string
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dlarocque committed Sep 9, 2024
1 parent 3670ab8 commit 454912f
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 += data.toString();
});
testProcess.childProcess.stderr.on('data', data => {
stderr += data.toString();
testProcessOutput += 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 454912f

Please sign in to comment.