Skip to content

Commit

Permalink
Merge pull request #1102 from w3c/report-errors-subprocess
Browse files Browse the repository at this point in the history
Report errors in subprocesses
  • Loading branch information
jugglinmike authored Jun 18, 2024
2 parents b720653 + aefb7f6 commit e4f4fa9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
16 changes: 16 additions & 0 deletions client/tests/util/getPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ const startServer = async serverOrClient => {
}
);

server.on('error', error => {
throw new Error('Error raised by startServer process', {
cause: error
});
});

server.on('exit', (code, signal) => {
if (code) {
console.error('startServer exited with code', code);
} else if (signal) {
console.error('startServer was killed with signal', signal);
} else {
console.info('startServer exited with no errors.'); // eslint-disable-line no-console
}
});

const killServer = async () => {
await new Promise((resolve, reject) => {
treeKill(server.pid, error => {
Expand Down
36 changes: 31 additions & 5 deletions server/scripts/import-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ const builtTestsDirectory = path.resolve(gitCloneDirectory, 'build', 'tests');
const testsDirectory = path.resolve(gitCloneDirectory, 'tests');

const gitRun = (args, cwd = gitCloneDirectory) => {
return spawn
.sync('git', args.split(' '), { cwd })
.stdout.toString()
.trimEnd();
const gitRunOutput = spawn.sync('git', args.split(' '), { cwd });

if (gitRunOutput.error) {
console.info(`'git ${args}' failed with error ${gitRunOutput.error}`);
process.exit(1);
}

return gitRunOutput.stdout.toString().trimEnd();
};

const importTestPlanVersions = async transaction => {
Expand Down Expand Up @@ -85,12 +89,23 @@ const buildTestsAndCreateTestPlanVersions = async (commit, { transaction }) => {
const installOutput = spawn.sync('npm', ['install'], {
cwd: gitCloneDirectory
});

if (installOutput.error) {
console.info(`'npm install' failed with error ${installOutput.error}`);
process.exit(1);
}
console.log('`npm install` output', installOutput.stdout.toString());

console.log('Running `npm run build` ...\n');
const buildOutput = spawn.sync('npm', ['run', 'build'], {
cwd: gitCloneDirectory
});

if (buildOutput.error) {
console.info(`'npm run build' failed with error ${buildOutput.error}`);
process.exit(1);
}

console.log('`npm run build` output', buildOutput.stdout.toString());

importHarness();
Expand Down Expand Up @@ -260,7 +275,18 @@ const cloneRepo = async () => {
fse.ensureDirSync(gitCloneDirectory);

console.info('Cloning aria-at repo ...');
spawn.sync('git', ['clone', ariaAtRepo, gitCloneDirectory]);
const cloneOutput = spawn.sync('git', [
'clone',
ariaAtRepo,
gitCloneDirectory
]);

if (cloneOutput.error) {
console.info(
`git clone ${ariaAtRepo} ${gitCloneDirectory} failed with error ${cloneOutput.error}`
);
process.exit(1);
}
console.info('Cloning aria-at repo complete.');
};

Expand Down

0 comments on commit e4f4fa9

Please sign in to comment.