Skip to content

feat: port 6_object_wrap test to CTS#32

Draft
kraenhansen wants to merge 2 commits intonodejs:mainfrom
kraenhansen:feat/port-6-object-wrap
Draft

feat: port 6_object_wrap test to CTS#32
kraenhansen wants to merge 2 commits intonodejs:mainfrom
kraenhansen:feat/port-6-object-wrap

Conversation

@kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented Mar 8, 2026

Summary

Note

Depends on #31 (stacked — includes that commit as the base) - review that first.

Ports the 6_object_wrap test suite from Node.js into the CTS. This is the first test to exercise the experimental addon infrastructure (add_node_api_cts_experimental_addon()), serving as end-to-end validation of #31.

Upstream source: https://github.com/nodejs/node/tree/main/test/js-native-api/6_object_wrap

Three build targets:

  • myobject (stable) — object wrap with getters/setters, plusOne, multiply
  • myobject_basic_finalizer (experimental, NAPI_EXPERIMENTAL) — basic finalizer verification, guarded by experimentalFeatures.postFinalizer
  • nested_wrap (NAPI_VERSION=10) — nested napi_ref finalization

Three JS test files:

  • test.js — property descriptors, constructor/plain-function invocation, method chaining
  • test-basic-finalizer.js — experimental finalizer with gcUntil, behind feature guard
  • nested_wrap.js — nested wrap finalization with gcUntil

All C++ source files are copied verbatim from upstream.

Test plan

  • npm run addons:configure && npm run addons:build — all three targets compile
  • npm run node:test — all 30 tests pass (3 new)
  • C++ files diff clean against upstream

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

kraenhansen and others added 2 commits March 8, 2026 13:24
Vendor Node-API headers from the Node.js repository (replacing the
node-api-headers npm package) and introduce infrastructure for
experimental feature support.

- Vendor headers from Node.js src/ into include/, including experimental
  API declarations behind #ifdef NAPI_EXPERIMENTAL
- Add scripts/update-headers.mjs to download headers and generate
  layered .def files via clang AST dump
- Add add_node_api_cts_experimental_addon() CMake function that defines
  NAPI_EXPERIMENTAL for addons using experimental APIs
- Add implementor feature declaration (features.js) with
  globalThis.experimentalFeatures for conditional test execution
- Add harness test validating the experimentalFeatures global, ensuring
  every expected feature is declared as a boolean

The .def files are deduplicated layers: js_native_api.def contains
stable engine-agnostic symbols, node_api.def adds stable runtime
symbols, and the _experimental variants add only experimental symbols.
CMake combines the layers when generating MSVC import libraries.

Closes nodejs#26
Port all three build targets and test files from upstream:
- myobject (stable) — object wrap with getters/setters/methods
- myobject_basic_finalizer (experimental) — basic finalizer verification
- nested_wrap (NAPI_VERSION=10) — nested ref finalization

The experimental target (myobject_basic_finalizer) exercises the
add_node_api_cts_experimental_addon() CMake function for the first time,
serving as end-to-end validation of the experimental infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kraenhansen kraenhansen moved this from Need Triage to Has PR in Node-API Team Project Mar 8, 2026
@kraenhansen kraenhansen marked this pull request as draft March 8, 2026 13:01
@kraenhansen
Copy link
Contributor Author

Drafting until #31 merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant