Skip to content

Commit

Permalink
Use bail out instead of throw (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbhoosreddy authored and nicolo-ribaudo committed Nov 21, 2019
1 parent f2e0cce commit 87976f5
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/compare-results/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ const path = require('path');
const fs = require('fs');
const _ = require('highland');
const diag = console.log.bind(console, '# ');
function throwIncorrectArgumentError() {
throw new Error(`master branch and PR artifact file paths required
Usage: node lib/compare-results master.tap test262.tap
`);
}

console.log('TAP version 13');

function throwMasterArtifactOutOfSyncError() {
throw new Error(`master branch and PR artifacts are out of sync. Was test262 sha updated in babel-test-runner?
Consider re-running the master branch test262 job to update the master branch artifact first!
`);
function bailOut(reason) {
console.log(`Bail out! ${reason}`);
process.exit(0); // tap-mocha-reporter will report correct failure code to CircleCI
}

function getFileNameFromTitle(title) {
Expand All @@ -33,16 +27,15 @@ async function main() {
const masterArtifactFileArg = process.argv[2];
const prArtifactFileArg = process.argv[3];
if (!(masterArtifactFileArg && prArtifactFileArg)) {
throwIncorrectArgumentError();
bailOut(`master branch and PR artifact file paths required. Usage: node lib/compare-results master.tap test262.tap`);
}
const masterArtifactFilePath = path.resolve(process.cwd(), masterArtifactFileArg);
const prArtifactFilePath = path.resolve(process.cwd(), prArtifactFileArg);

const [masterTests, prTests] = await Promise.all([parseTestResults(masterArtifactFilePath), parseTestResults(prArtifactFilePath)]);

if (masterTests.length !== prTests.length) {
console.error('Master and PR artifacts out of sync! Reason: Different number of tests.');
throwMasterArtifactOutOfSyncError();
bailOut(`master branch and PR artifacts are out of sync. Possible reasons include intermittent-tests.txt or test262 sha was updated. Consider re-running the master branch test262 job to update the master branch artifact first!`);
}
const masterTestsMap = masterTests.reduce((acc, test) => {
if (test.type === 'assertion') {
Expand Down

0 comments on commit 87976f5

Please sign in to comment.