Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console: lazy load process.stderr and process.stdout #24534

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions test/parallel/test-bootstrap-modules.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
/* eslint-disable node-core/required-modules */

// Flags: --expose-internals
'use strict';

// Ordinarily test files must require('common') but that action causes
// the global console to be compiled, defeating the purpose of this test.
// This makes sure no additional files are added without carefully considering
// lazy loading. Please adjust the value if necessary.

// This list must be computed before we require any modules to
// to eliminate the noise.
const list = process.moduleLoadList.slice();

require('../common');
const assert = require('assert');

assert(list.length <= 56, list);
// We use the internals to detect if this test is run in a worker
// to eliminate the noise introduced by --experimental-worker
const { internalBinding } = require('internal/test/binding');
const { threadId } = internalBinding('worker');
const isMainThread = threadId === 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.isMainThread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardlau Didn't know about this, thanks!

const kMaxModuleCount = isMainThread ? 56 : 78;

assert(list.length <= kMaxModuleCount,
`Total length: ${list.length}\n` + list.join('\n')
);