electron/patches/node/test_fix_edge_snapshot_stack_traces.patch
Shelley Vohr 9c94fd7afb
chore: upgrade to Node.js v20 (#40545)
* chore: upgrade to Node.js v20

* src: allow embedders to override NODE_MODULE_VERSION

https://github.com/nodejs/node/pull/49279

* src: fix missing trailing ,

https://github.com/nodejs/node/pull/46909

* src,tools: initialize cppgc

https://github.com/nodejs/node/pull/45704

* tools: allow passing absolute path of config.gypi in js2c

https://github.com/nodejs/node/pull/49162

* tools: port js2c.py to C++

https://github.com/nodejs/node/pull/46997

* doc,lib: disambiguate the old term, NativeModule

https://github.com/nodejs/node/pull/45673

* chore: fixup Node.js BSSL tests

* https://github.com/nodejs/node/pull/49492
* https://github.com/nodejs/node/pull/44498

* deps: upgrade to libuv 1.45.0

https://github.com/nodejs/node/pull/48078

* deps: update V8 to 10.7

https://github.com/nodejs/node/pull/44741

* test: use gcUntil() in test-v8-serialize-leak

https://github.com/nodejs/node/pull/49168

* module: make CJS load from ESM loader

https://github.com/nodejs/node/pull/47999

* src: make BuiltinLoader threadsafe and non-global

https://github.com/nodejs/node/pull/45942

* chore: address changes to CJS/ESM loading

* module: make CJS load from ESM loader (https://github.com/nodejs/node/pull/47999)
* lib: improve esm resolve performance (https://github.com/nodejs/node/pull/46652)

* bootstrap: optimize modules loaded in the built-in snapshot

https://github.com/nodejs/node/pull/45849

* test: mark test-runner-output as flaky

https://github.com/nodejs/node/pull/49854

* lib: lazy-load deps in modules/run_main.js

https://github.com/nodejs/node/pull/45849

* url: use private properties for brand check

https://github.com/nodejs/node/pull/46904

* test: refactor `test-node-output-errors`

https://github.com/nodejs/node/pull/48992

* assert: deprecate callTracker

https://github.com/nodejs/node/pull/47740

* src: cast v8::Object::GetInternalField() return value to v8::Value

https://github.com/nodejs/node/pull/48943

* test: adapt test-v8-stats for V8 update

https://github.com/nodejs/node/pull/45230

* tls: ensure TLS Sockets are closed if the underlying wrap closes

https://github.com/nodejs/node/pull/49327

* test: deflake test-tls-socket-close

https://github.com/nodejs/node/pull/49575

* net: fix crash due to simultaneous close/shutdown on JS Stream Sockets

https://github.com/nodejs/node/pull/49400

* net: use asserts in JS Socket Stream to catch races in future

https://github.com/nodejs/node/pull/49400

* lib: fix BroadcastChannel initialization location

https://github.com/nodejs/node/pull/46864

* src: create BaseObject with node::Realm

https://github.com/nodejs/node/pull/44348

* src: implement DataQueue and non-memory resident Blob

https://github.com/nodejs/node/pull/45258

* sea: add support for V8 bytecode-only caching

https://github.com/nodejs/node/pull/48191

* chore: fixup patch indices

* gyp: put filenames in variables

https://github.com/nodejs/node/pull/46965

* build: modify js2c.py into GN executable

* fix: (WIP) handle string replacement of fs -> original-fs

* [v20.x] backport vm-related memory fixes

https://github.com/nodejs/node/pull/49874

* src: make BuiltinLoader threadsafe and non-global

https://github.com/nodejs/node/pull/45942

* src: avoid copying string in fs_permission

https://github.com/nodejs/node/pull/47746

* look upon my works ye mighty

and dispair

* chore: patch cleanup

* [api] Remove AllCan Read/Write

https://chromium-review.googlesource.com/c/v8/v8/+/5006387

* fix: missing include for NODE_EXTERN

* chore: fixup patch indices

* fix: fail properly when js2c fails in Node.js

* build: fix js2c root_gen_dir

* fix: lib/fs.js -> lib/original-fs.js

* build: fix original-fs file xforms

* fixup! module: make CJS load from ESM loader

* build: get rid of CppHeap for now

* build: add patch to prevent extra fs lookup on esm load

* build: greatly simplify js2c modifications

Moves our original-fs modifications back into a super simple python script action, wires up the output of that action into our call to js2c

* chore: update to handle moved internal/modules/helpers file

* test: update @types/node test

* feat: enable preventing cppgc heap creation

* feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler

* fix: no cppgc initialization in the renderer

* gyp: put filenames in variables

https://github.com/nodejs/node/pull/46965

* test: disable single executable tests

* fix: nan tests failing on node headers missing file

* tls,http2: send fatal alert on ALPN mismatch

https://github.com/nodejs/node/pull/44031

* test: disable snapshot tests

* https://github.com/nodejs/node/pull/47887
* https://github.com/nodejs/node/pull/49684
* https://github.com/nodejs/node/pull/44193

* build: use deps/v8 for v8/tools

Node.js hard depends on these in their builtins

* test: fix edge snapshot stack traces

https://github.com/nodejs/node/pull/49659

* build: remove js2c //base dep

* build: use electron_js2c_toolchain to build node_js2c

* fix: don't create SafeSet outside packageResolve

Fixes failure in parallel/test-require-delete-array-iterator:

=== release test-require-delete-array-iterator ===
Path: parallel/test-require-delete-array-iterator
node:internal/per_context/primordials:426
    constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
                     ^

TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
    at new Set (<anonymous>)
    at new SafeSet (node:internal/per_context/primordials:426:22)

* fix: failing crashReporter tests on Linux

These were failing because our change from node::InitializeNodeWithArgs to
node::InitializeOncePerProcess meant that we now inadvertently called
PlatformInit, which reset signal handling. This meant that our intentional
crash function ElectronBindings::Crash no longer worked and the renderer process
no longer crashed when process.crash() was called. We don't want to use Node.js'
default signal handling in the renderer process, so we disable it by passing
kNoDefaultSignalHandling to node::InitializeOncePerProcess.

* build: only create cppgc heap on non-32 bit platforms

* chore: clean up util:CompileAndCall

* src: fix compatility with upcoming V8 12.1 APIs

https://github.com/nodejs/node/pull/50709

* fix: use thread_local BuiltinLoader

* chore: fixup v8 patch indices

---------

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
2023-11-30 09:51:35 -05:00

151 lines
7.3 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 18 Oct 2023 10:40:34 +0200
Subject: test: fix edge snapshot stack traces
https://github.com/nodejs/node/pull/49659
diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js
index 838ee86f74ea89e052676a5c25e23481369857fa..3aacfa064561c64c218fcc4e3090f7952cb1d218 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -8,6 +8,10 @@ const assert = require('node:assert/strict');
const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const windowNewlineRegexp = /\r/g;
+function replaceNodeVersion(str) {
+ return str.replaceAll(process.version, '*');
+}
+
function replaceStackTrace(str, replacement = '$1*$7$8\n') {
return str.replace(stackFramesRegexp, replacement);
}
@@ -84,6 +88,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
module.exports = {
assertSnapshot,
getSnapshotPath,
+ replaceNodeVersion,
replaceFullPaths,
replaceStackTrace,
replaceWindowsLineEndings,
diff --git a/test/fixtures/errors/force_colors.snapshot b/test/fixtures/errors/force_colors.snapshot
index be1d45d0d8e8ba7b637754e32fe379cb2cf1e6ac..21410d492db861876ecfcb82dcc3c1815cba6d09 100644
--- a/test/fixtures/errors/force_colors.snapshot
+++ b/test/fixtures/errors/force_colors.snapshot
@@ -4,11 +4,12 @@ throw new Error('Should include grayed stack trace')
Error: Should include grayed stack trace
at Object.<anonymous> (/test*force_colors.js:1:7)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
- at Module._extensions..js (node:internal*modules*cjs*loader:1295:10)
- at Module.load (node:internal*modules*cjs*loader:1091:32)
- at Module._load (node:internal*modules*cjs*loader:938:12)
- at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12)
- at node:internal*main*run_main_module:23:47
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
Node.js *
diff --git a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
index 2c1e11eeb9eab1bcb101f8f5af909461b26036ec..6a109c904e115503b743d5c4e0418ae693ca9856 100644
--- a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
+++ b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
@@ -1,3 +1,3 @@
Error: an exception.
at Object.<anonymous> (*typescript-sourcemapping_url_string.ts:3:7)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
+ *
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index b08bcd40cdf26093e158c0bb9ae566c76f2c731e..bf8eacbac479a2bf5698ed29ede648e149f185b5 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -10,15 +10,15 @@ const skipForceColors =
process.config.variables.node_shared_openssl ||
(common.isWindows && (Number(os.release().split('.')[0]) !== 10 || Number(os.release().split('.')[2]) < 14393)); // See https://github.com/nodejs/node/pull/33132
-
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
-
function replaceStackTrace(str) {
return snapshot.replaceStackTrace(str, '$1at *$7\n');
}
+function replaceForceColorsStackTrace(str) {
+ // eslint-disable-next-line no-control-regex
+ return str.replaceAll(/(\[90m\W+)at .*node:.*/g, '$1at *');
+}
+
describe('errors output', { concurrency: true }, () => {
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
@@ -35,9 +35,12 @@ describe('errors output', { concurrency: true }, () => {
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths);
- const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion);
- const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion);
- const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion);
+ const defaultTransform = snapshot.transform(common, normalize, snapshot.replaceNodeVersion);
+ const errTransform = snapshot.transform(common, normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const promiseTransform = snapshot.transform(common, replaceStackTrace,
+ normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const forceColorsTransform = snapshot.transform(common, normalize,
+ replaceForceColorsStackTrace, snapshot.replaceNodeVersion);
const tests = [
{ name: 'errors/async_error_eval_cjs.js' },
@@ -57,7 +60,11 @@ describe('errors output', { concurrency: true }, () => {
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{ name: 'errors/throw_non_error.js', transform: errTransform },
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
- { skip: skipForceColors, name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } },
+ !skipForceColors ? {
+ name: 'errors/force_colors.js',
+ transform: forceColorsTransform,
+ env: { FORCE_COLOR: 1 }
+ } : null,
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {
diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs
index 2043fa57f06a8d2326a4ea1ba24341502c8b7471..b01f30765c7de81a4d956b9c1124affea0fc2aef 100644
--- a/test/parallel/test-node-output-sourcemaps.mjs
+++ b/test/parallel/test-node-output-sourcemaps.mjs
@@ -4,10 +4,6 @@ import * as snapshot from '../common/assertSnapshot.js';
import * as path from 'node:path';
import { describe, it } from 'node:test';
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
-
describe('sourcemaps output', { concurrency: true }, () => {
function normalize(str) {
const result = str
@@ -16,7 +12,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
.replaceAll('/Users/bencoe/oss/coffee-script-test', '')
.replaceAll(/\/(\w)/g, '*$1')
.replaceAll('*test*', '*')
- .replaceAll('*fixtures*source-map*', '*');
+ .replaceAll('*fixtures*source-map*', '*')
+ .replaceAll(/(\W+).*node:internal\*modules.*/g, '$1*');
if (common.isWindows) {
const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase();
const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi');
@@ -25,7 +22,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
return result;
}
const defaultTransform = snapshot
- .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);
+ .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths,
+ normalize, snapshot.replaceNodeVersion);
const tests = [
{ name: 'source-map/output/source_map_disabled_by_api.js' },