Skip to content

Commit

Permalink
Prevent comparision on CircleCI master (#16)
Browse files Browse the repository at this point in the history
* Prevent comparision on CircleCI master

* test.title needs to be unique if we need to rely on it
  • Loading branch information
jbhoosreddy authored and nicolo-ribaudo committed Nov 6, 2019
1 parent b184ad0 commit fc0e926
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
22 changes: 14 additions & 8 deletions lib/compare-results/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ const parser = require('@tap-format/parser')
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');
diag(`CIRCLECI = ${process.env.CIRCLECI}`);
diag(`CIRCLE_BRANCH = ${process.env.CIRCLE_BRANCH}`);
const isCircleCIMaster = process.env.CIRCLECI && process.env.CIRCLE_BRANCH === 'master';
diag(`is CircleCI master branch job: ${isCircleCIMaster}`);

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!
Expand Down Expand Up @@ -41,17 +47,17 @@ async function main() {
return acc;
}, {});
for (let i = 0; i < prTests.length; i++) {
const prTest = prTests[i];
if (!Object.prototype.hasOwnProperty.call(masterTestsMap, prTest.title)) {
console.log(`# Ignoring test '${prTest.title}' as it was not found in master artifact!`);
continue;
if (isCircleCIMaster) {
return;
}
const prTest = prTests[i];
const masterTest = masterTestsMap[prTest.title];
switch (prTest.type) {
case 'version':
console.log(prTest.raw);
break;
case 'assertion':
if (!Object.prototype.hasOwnProperty.call(masterTestsMap, prTest.title)) {
diag(`Ignoring test '${prTest.title}' as it was not found in master artifact!`);
continue;
}
if (prTest.ok !== masterTest.ok) {
console.log(prTest.raw);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/run-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ async function main() {
if (actual.result === expected) {
passed++;
tap.pass(
`${file} (${expected})`
file,
`(${expected})`
);
} else {
tap.fail(
`${file} (expected ${expected}, got ${actual.result})`,
file,
`(expected ${expected}, got ${actual.result})`,
new RethrownError(actual.error)
);
}
Expand Down

0 comments on commit fc0e926

Please sign in to comment.