diff --git a/scripts/binary/binary-integrity-check-source.js b/scripts/binary/binary-integrity-check-source.js index a6892a47d887..683d5381aeaa 100644 --- a/scripts/binary/binary-integrity-check-source.js +++ b/scripts/binary/binary-integrity-check-source.js @@ -31,9 +31,25 @@ const stackIntegrityCheck = function stackIntegrityCheck (options) { if (stack.length !== options.stackToMatch.length) { console.error(`Integrity check failed with expected stack length ${options.stackToMatch.length} but got ${stack.length}`) + throw new Error(integrityErrorMessage) } + // console.log('expected stack frames:', JSON.stringify(options.stackToMatch, null, 2)) + // for (const expectedStackFrame of options.stackToMatch) { + // console.log(' ', JSON.stringify(expectedStackFrame, null, 2)) + // } + + // console.log('actual stack frames:') + // for (const actualStackFrame of stack) { + // console.log(' ', JSON.stringify({ + // functionName: actualStackFrame.getFunctionName(), + // fileName: actualStackFrame.getFileName(), + // line: actualStackFrame.getLineNumber(), + // column: actualStackFrame.getColumnNumber(), + // }, null, 2)) + // } + for (let index = 0; index < options.stackToMatch.length; index++) { const { functionName: expectedFunctionName, fileName: expectedFileName, line: expectedLineNumber, column: expectedColumnNumber } = options.stackToMatch[index] const actualFunctionName = stack[index].getFunctionName() @@ -65,21 +81,21 @@ const stackIntegrityCheck = function stackIntegrityCheck (options) { function validateStartsWith () { if (originalStartsWith.call !== originalCallFn) { - console.error(`Integrity check failed for startsWith.call`) + console.error(`Integrity check failed for startsWith.call ${originalStartsWith.call}`) throw new Error(integrityErrorMessage) } } function validateFilter () { if (originalFilter.call !== originalCallFn) { - console.error(`Integrity check failed for filter.call`) + console.error(`Integrity check failed for filter.call ${originalFilter.call}`) throw new Error(integrityErrorMessage) } } function validateToString () { if (originalToString.call !== originalCallFn) { - console.error(`Integrity check failed for toString.call`) + console.error(`Integrity check failed for toString.call ${originalToString.call}`) throw new Error(integrityErrorMessage) } } @@ -94,7 +110,7 @@ function validateElectron (electron) { function validateFs (fs) { // Hard coded function as this is electron code and there's not an easy way to get the function string at package time. If this fails on an updated version of electron, we'll need to update this. - if (originalToString.call(fs.readFileSync) !== `function(e,r){const n=splitPath(e);if(!n.isAsar)return w.apply(this,arguments);const{asarPath:i,filePath:a}=n,o=getOrCreateArchive(i);if(!o)throw createError("INVALID_ARCHIVE",{asarPath:i});const c=o.getFileInfo(a);if(!c)throw createError("NOT_FOUND",{asarPath:i,filePath:a});if(0===c.size)return r?"":s.Buffer.alloc(0);if(c.unpacked){const e=o.copyFileOut(a);return t.readFileSync(e,r)}if(r){if("string"==typeof r)r={encoding:r};else if("object"!=typeof r)throw new TypeError("Bad arguments")}else r={encoding:null};const{encoding:f}=r,l=s.Buffer.alloc(c.size),u=o.getFdAndValidateIntegrityLater();if(!(u>=0))throw createError("NOT_FOUND",{asarPath:i,filePath:a});return logASARAccess(i,a,c.offset),t.readSync(u,l,0,c.size,c.offset),validateBufferIntegrity(l,c.integrity),f?l.toString(f):l}`) { + if (originalToString.call(fs.readFileSync) !== `function(t,e){const r=splitPath(t);return r.isAsar?readFileFromArchiveSync(r,e):R.apply(this,arguments)}`) { console.error(`Integrity check failed for toString.call(fs.readFileSync)`) throw new Error(integrityErrorMessage) } @@ -190,6 +206,10 @@ function integrityCheck (options) { line: 1, column: 2764, }, + { + functionName: 'traceSync', + fileName: 'node:diagnostics_channel', + }, ], }) diff --git a/scripts/binary/index.js b/scripts/binary/index.js index 88aa75b7d9f8..40d9bacf1ad5 100644 --- a/scripts/binary/index.js +++ b/scripts/binary/index.js @@ -78,8 +78,10 @@ async function testExecutableVersion (buildAppExecutable, version) { la(result.stdout, 'missing output when getting built version', result) console.log('built app version', result.stdout) - la(result.stdout.trim() === version.trim(), 'different version reported', - result.stdout, 'from input version to build', version) + la( + result.stdout.trim() === version.trim(), + `different version reported: '${result.stdout.trim()}' from input version to build '${version.trim()}'`, + ) console.log('✅ using --version on the Cypress binary works') } diff --git a/scripts/binary/smoke.js b/scripts/binary/smoke.js index 7962bc191144..fdc0a97ce0d2 100644 --- a/scripts/binary/smoke.js +++ b/scripts/binary/smoke.js @@ -285,7 +285,7 @@ const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) { await fs.remove(path.join(buildAppDir, 'index2.js')) } - await testAlteringEntryPoint('console.log("simple alteration")', 'Integrity check failed with expected stack length 9 but got 10') + await testAlteringEntryPoint('console.log("simple alteration")', 'Integrity check failed with expected stack length 10 but got 12') await testAlteringEntryPoint('console.log("accessing " + global.getSnapshotResult())', 'getSnapshotResult can only be called once') function compareGlobals () { @@ -299,9 +299,9 @@ const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) { console.error(`extra keys in electron process: ${extraKeys}`) } - const allowList = ['__core-js_shared__', 'getSnapshotResult', 'supportTypeScript', 'Iterator'] + const allowList = ['__core-js_shared__', 'getSnapshotResult', 'supportTypeScript', 'SuppressedError', 'DisposableStack', 'AsyncDisposableStack', 'Float16Array'] - await testAlteringEntryPoint(`(${compareGlobals.toString()})()`, `extra keys in electron process: ${allowList}\nIntegrity check failed with expected stack length 9 but got 10`) + await testAlteringEntryPoint(`(${compareGlobals.toString()})()`, `extra keys in electron process: ${allowList}\nIntegrity check failed with expected stack length 10 but got 12`) const testTemporarilyRewritingEntryPoint = async () => { const file = path.join(buildAppDir, 'index.js') diff --git a/scripts/binary/trigger-publish-binary-pipeline.js b/scripts/binary/trigger-publish-binary-pipeline.js index f47bc2ebb498..4dafe153e350 100644 --- a/scripts/binary/trigger-publish-binary-pipeline.js +++ b/scripts/binary/trigger-publish-binary-pipeline.js @@ -10,6 +10,7 @@ const { getNextVersionForBinary } = require('../get-next-version') const { nextVersion } = await getNextVersionForBinary() const body = JSON.stringify({ + branch: 'electron-36', parameters: { temp_dir: os.tmpdir(), sha: process.env.CIRCLE_SHA1,