From 3367290bb3e4cfae43efa8dd551a0d348c2181da Mon Sep 17 00:00:00 2001 From: jbhoosreddy Date: Wed, 6 Nov 2019 21:12:50 -0500 Subject: [PATCH 1/3] Properly compare test files between jobs --- lib/compare-results/index.js | 20 +++++++++++++++----- package-lock.json | 20 ++++++++++++++------ package.json | 1 + 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/compare-results/index.js b/lib/compare-results/index.js index 92c257b..980e24e 100644 --- a/lib/compare-results/index.js +++ b/lib/compare-results/index.js @@ -21,6 +21,12 @@ function throwMasterArtifactOutOfSyncError() { `); } +function getfileNameFromTitle(title) { + return title ? + title.split('#')[0].trim() : + undefined; +} + function parseTestResults(filePath) { return new Promise(resolve => _(fs.createReadStream(filePath).pipe(parser.stream())) .map(buffer => JSON.parse(buffer.toString())) @@ -43,19 +49,23 @@ async function main() { throwMasterArtifactOutOfSyncError(); } const masterTestsMap = masterTests.reduce((acc, test) => { - acc[test.title] = test; + if (test.type === 'assertion') { + acc[getfileNameFromTitle(test.title)] = test; + } return acc; - }, {}); + }, Object.create(null)); + for (let i = 0; i < prTests.length; i++) { if (isCircleCIMaster) { return; } const prTest = prTests[i]; - const masterTest = masterTestsMap[prTest.title]; + const fileName = getfileNameFromTitle(prTest.title); + const masterTest = masterTestsMap[fileName]; switch (prTest.type) { case 'assertion': - if (!Object.prototype.hasOwnProperty.call(masterTestsMap, prTest.title)) { - diag(`Ignoring test '${prTest.title}' as it was not found in master artifact!`); + if (!(fileName in masterTestsMap)) { + diag(`Ignoring test '${fileName}' as it was not found in master artifact!`); continue; } if (prTest.ok !== masterTest.ok) { diff --git a/package-lock.json b/package-lock.json index 792999d..85d49eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1606,9 +1606,9 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { - "version": "3.0.1", - "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/minipass/-/minipass-3.0.1.tgz", - "integrity": "sha1-tP7HO9YeikDws3Td0EJgreLI7CA=", + "version": "3.1.1", + "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/minipass/-/minipass-3.1.1.tgz", + "integrity": "sha1-dgfOd4RyoYWtbYkIKqIHD3nO3NU=", "requires": { "yallist": "^4.0.0" } @@ -2158,6 +2158,14 @@ "has-flag": "^3.0.0" } }, + "tap-merge": { + "version": "0.3.1", + "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/tap-merge/-/tap-merge-0.3.1.tgz", + "integrity": "sha1-H7vaGwngLb193YzU7fi5utEYSpE=", + "requires": { + "highland": "^2.5.1" + } + }, "tap-mocha-reporter": { "version": "5.0.0", "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/tap-mocha-reporter/-/tap-mocha-reporter-5.0.0.tgz", @@ -2190,9 +2198,9 @@ } }, "tap-parser": { - "version": "10.0.0", - "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/tap-parser/-/tap-parser-10.0.0.tgz", - "integrity": "sha1-Sj6zYgpBtPthNrm8bweVVyPVauo=", + "version": "10.0.1", + "resolved": "http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/tap-parser/-/tap-parser-10.0.1.tgz", + "integrity": "sha1-tjwlAO7vK+j78J1RKRQZbR8S6+w=", "requires": { "events-to-array": "^1.0.1", "minipass": "^3.0.0", diff --git a/package.json b/package.json index dd1e5d3..ab0ab2e 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "progress": "^2.0.3", "regenerator-runtime": "^0.13.3", "rimraf": "^3.0.0", + "tap-merge": "^0.3.1", "tap-mocha-reporter": "^5.0.0", "targz": "^1.0.1", "tempy": "^0.3.0", From c330fa32af26450a22ac61ffb0407480d92d425b Mon Sep 17 00:00:00 2001 From: Jaideep Bhoosreddy Date: Fri, 8 Nov 2019 17:35:29 -0500 Subject: [PATCH 2/3] Fix casing --- lib/compare-results/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/compare-results/index.js b/lib/compare-results/index.js index 980e24e..bfd3a59 100644 --- a/lib/compare-results/index.js +++ b/lib/compare-results/index.js @@ -21,7 +21,7 @@ function throwMasterArtifactOutOfSyncError() { `); } -function getfileNameFromTitle(title) { +function getFileNameFromTitle(title) { return title ? title.split('#')[0].trim() : undefined; @@ -50,7 +50,7 @@ async function main() { } const masterTestsMap = masterTests.reduce((acc, test) => { if (test.type === 'assertion') { - acc[getfileNameFromTitle(test.title)] = test; + acc[getFileNameFromTitle(test.title)] = test; } return acc; }, Object.create(null)); @@ -60,7 +60,7 @@ async function main() { return; } const prTest = prTests[i]; - const fileName = getfileNameFromTitle(prTest.title); + const fileName = getFileNameFromTitle(prTest.title); const masterTest = masterTestsMap[fileName]; switch (prTest.type) { case 'assertion': From 449f84bf2825d67d90f3b55d0bc2139e5aa27617 Mon Sep 17 00:00:00 2001 From: jbhoosreddy Date: Fri, 8 Nov 2019 20:58:06 -0500 Subject: [PATCH 3/3] Fix error for modules parsed as scripts --- lib/run-tests/index.js | 7 +++++-- lib/run-tests/transpile.js | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/run-tests/index.js b/lib/run-tests/index.js index f706f9a..5fb5b08 100644 --- a/lib/run-tests/index.js +++ b/lib/run-tests/index.js @@ -92,9 +92,10 @@ function getExpected({ attrs }) { async function runTest(agent, test) { let { attrs, contents, file } = test; + const isModule = attrs.flags.module; try { - contents = transpile(contents, attrs.features); + contents = transpile(contents, attrs.features, isModule); } catch (error) { return { result: "parser error", error }; } @@ -146,9 +147,11 @@ class RethrownError extends ExtendedError { if (!error) throw new Error('RethrownError requires an error'); this.original = error; this.new_stack = this.stack; + const errorStackString = error.stack && (typeof error.stack === 'string' ? + error.stack : error.stack.map(location => location.source).join('\n')); let message_lines = (this.message.match(/\n/g) || []).length + 1; this.stack = `${this.name}: ${this.message}\n${ this.stack.split('\n').slice(0, message_lines + 1).join('\n') - }\n${error.stack.map(location => location.source).join('\n')}`; + }\n${errorStackString}`; } } diff --git a/lib/run-tests/transpile.js b/lib/run-tests/transpile.js index 47aa085..4deeedb 100644 --- a/lib/run-tests/transpile.js +++ b/lib/run-tests/transpile.js @@ -7,7 +7,7 @@ const getBabelPlugins = require("./get-babel-plugins"); const configCaches = new Map(); -function getOptions(features) { +function getOptions(features, isModule) { const featureKey = JSON.stringify(features); let config = configCaches.get(featureKey); if (config !== undefined) { @@ -17,13 +17,13 @@ function getOptions(features) { configFile: false, presets: [[presetEnv, { spec: true }]], plugins: getBabelPlugins(features), - sourceType: "script", + sourceType: isModule ? "module" : "script", }); configCaches.set(featureKey, config); return config; } -module.exports = function transpile(code, features) { - return transformSync(code, getOptions(features)).code; +module.exports = function transpile(code, features, isModule) { + return transformSync(code, getOptions(features, isModule)).code; };