node/test/pummel/test-heapdump-env.js
Joyee Cheung e86adad759 test: use validateByRetainingPath in heapdump tests
This makes sure that the tests are run on actual heap snapshots
and prints out missing paths when it cannot be found, which
makes failures easier to debug, and removes the unnecessary
requirement for BaseObjects to be root - which would make
the heap snapshot containment view rather noisy and is not
conceptually correct, since they are actually held by the
BaseObjectList held by the realms.

PR-URL: https://github.com/nodejs/node/pull/57417
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-04-27 19:00:05 +00:00

28 lines
1.1 KiB
JavaScript

'use strict';
// This tests that Environment is tracked in heap snapshots.
// Tests for BaseObject and cppgc-managed objects are done in other
// test-heapdump-*.js files.
require('../common');
const { createJSHeapSnapshot, validateByRetainingPathFromNodes } = require('../common/heap');
const nodes = createJSHeapSnapshot();
const envs = validateByRetainingPathFromNodes(nodes, 'Node / Environment', []);
validateByRetainingPathFromNodes(envs, 'Node / Environment', [
{ node_name: 'Node / CleanupQueue', edge_name: 'cleanup_queue' },
]);
validateByRetainingPathFromNodes(envs, 'Node / Environment', [
{ node_name: 'Node / IsolateData', edge_name: 'isolate_data' },
]);
const realms = validateByRetainingPathFromNodes(envs, 'Node / Environment', [
{ node_name: 'Node / PrincipalRealm', edge_name: 'principal_realm' },
]);
validateByRetainingPathFromNodes(realms, 'Node / PrincipalRealm', [
{ node_name: 'process', edge_name: 'process_object' },
]);
validateByRetainingPathFromNodes(realms, 'Node / PrincipalRealm', [
{ node_name: 'Node / BaseObjectList', edge_name: 'base_object_list' },
]);