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

test: simplify common/index.js #56712

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jan 22, 2025

Multiple improvements in tests and the test harness

  • Eliminate single or limited use utilities from common/index.js in order to generally reduce reliance on the custom test harness
  • Replace uses of the older Node.js-specific global in favor of globalThis
  • Handful of other cleanups

See individual commit messages for more detail.

Move single or trivial and limited use things out of
common/index.js for the purpose of simplifying and reducing
common/index.js
There are several cleanups here that are not just style nits...

1. The `common.isMainThread` was just a passthrough to the
   `isMainThread` export on the worker_thread module. It's
   use was inconsistent and just obfuscated the fact that
   the test file depend on the `worker_threads` built-in.
   By eliminating it we simplify the test harness a bit and
   make it clearer which tests depend on the worker_threads
   check.
2. The `common.isDumbTerminal` is fairly unnecesary since
   that just wraps a public API check.
3. Several of the `common.skipIf....` checks were inconsistently
   used and really don't need to be separate utility functions.

A key part of the motivation here is to work towards making more
of the tests more self-contained and less reliant on the common
test harness where possible.
* s/global/globalThis
* clean up knownGlobals a bit, make it a Set instead of an array
  and condense a bit.
@jasnell jasnell requested review from mcollina and anonrig January 22, 2025 23:33
@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jan 22, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.22%. Comparing base (9ec7bed) to head (ef9cb6d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56712      +/-   ##
==========================================
+ Coverage   89.20%   89.22%   +0.01%     
==========================================
  Files         662      662              
  Lines      191934   191934              
  Branches    36944    36948       +4     
==========================================
+ Hits       171218   171246      +28     
+ Misses      13552    13538      -14     
+ Partials     7164     7150      -14     

see 36 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants