Skip to content

Commit 6cc7cb7

Browse files
kraenhansenclaude
andcommitted
doc: update PORTING.md with ported status and experimental API notes
Mark 17 easy js-native-api tests as Ported (test_dataview as Partial due to missing experimental SharedArrayBuffer APIs in node-api-headers). Add "Experimental Node-API Features" section documenting which tests depend on experimental APIs not yet available in node-api-headers, and the approach needed to support them. References #26. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b5f53a2 commit 6cc7cb7

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

PORTING.md

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,36 @@ Tests covering the engine-specific part of Node-API, defined in `js_native_api.h
4141
| Directory | Status | Difficulty |
4242
| ---------------------------- | ---------- | ---------- |
4343
| `2_function_arguments` | Ported ||
44-
| `3_callbacks` | Not ported | Easy |
45-
| `4_object_factory` | Not ported | Easy |
46-
| `5_function_factory` | Not ported | Easy |
44+
| `3_callbacks` | Ported | Easy |
45+
| `4_object_factory` | Ported | Easy |
46+
| `5_function_factory` | Ported | Easy |
4747
| `6_object_wrap` | Not ported | Medium |
48-
| `7_factory_wrap` | Not ported | Easy |
49-
| `8_passing_wrapped` | Not ported | Easy |
50-
| `test_array` | Not ported | Easy |
51-
| `test_bigint` | Not ported | Easy |
48+
| `7_factory_wrap` | Ported | Easy |
49+
| `8_passing_wrapped` | Ported | Easy |
50+
| `test_array` | Ported | Easy |
51+
| `test_bigint` | Ported | Easy |
5252
| `test_cannot_run_js` | Not ported | Medium |
5353
| `test_constructor` | Not ported | Medium |
5454
| `test_conversions` | Not ported | Medium |
55-
| `test_dataview` | Not ported | Easy |
56-
| `test_date` | Not ported | Easy |
55+
| `test_dataview` | Partial | Easy |
56+
| `test_date` | Ported | Easy |
5757
| `test_error` | Not ported | Medium |
5858
| `test_exception` | Not ported | Medium |
5959
| `test_finalizer` | Not ported | Medium |
6060
| `test_function` | Not ported | Medium |
6161
| `test_general` | Not ported | Hard |
62-
| `test_handle_scope` | Not ported | Easy |
63-
| `test_instance_data` | Not ported | Easy |
64-
| `test_new_target` | Not ported | Easy |
65-
| `test_number` | Not ported | Easy |
62+
| `test_handle_scope` | Ported | Easy |
63+
| `test_instance_data` | Ported | Easy |
64+
| `test_new_target` | Ported | Easy |
65+
| `test_number` | Ported | Easy |
6666
| `test_object` | Not ported | Hard |
67-
| `test_promise` | Not ported | Easy |
68-
| `test_properties` | Not ported | Easy |
67+
| `test_promise` | Ported | Easy |
68+
| `test_properties` | Ported | Easy |
6969
| `test_reference` | Not ported | Medium |
70-
| `test_reference_double_free` | Not ported | Easy |
70+
| `test_reference_double_free` | Ported | Easy |
7171
| `test_sharedarraybuffer` | Not ported | Medium |
7272
| `test_string` | Not ported | Medium |
73-
| `test_symbol` | Not ported | Easy |
73+
| `test_symbol` | Ported | Easy |
7474
| `test_typedarray` | Not ported | Medium |
7575

7676
## Runtime-specific (`node-api`)
@@ -106,6 +106,33 @@ Tests covering the runtime-specific part of Node-API, defined in `node_api.h`.
106106
| `test_worker_terminate` | Not ported | Hard |
107107
| `test_worker_terminate_finalization` | Not ported | Hard |
108108

109+
## Experimental Node-API Features
110+
111+
Several tests in the upstream Node.js repository use experimental APIs that are guarded behind
112+
`#ifdef NAPI_EXPERIMENTAL` in Node.js's `js_native_api.h`. The `node-api-headers` package (which
113+
the CTS uses for compilation) does not currently include any of these experimental API declarations.
114+
115+
When `NAPI_EXPERIMENTAL` is defined in Node.js, `NAPI_VERSION` is set to
116+
`NAPI_VERSION_EXPERIMENTAL (2147483647)`. The `NAPI_MODULE` macro exports this version, and the
117+
runtime uses it to decide whether to enable experimental behavior for that addon.
118+
119+
| Feature macro | APIs | Used by |
120+
|---|---|---|
121+
| `NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER` | `node_api_is_sharedarraybuffer`, `node_api_create_sharedarraybuffer` | `test_dataview`, `test_sharedarraybuffer` |
122+
| `NODE_API_EXPERIMENTAL_HAS_CREATE_OBJECT_WITH_PROPERTIES` | `node_api_create_object_with_properties` | `test_object` |
123+
| `NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE` | `node_api_set_prototype` | `test_general` |
124+
| `NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER` | `node_api_post_finalizer` | `test_general`, `test_finalizer`, `6_object_wrap` |
125+
126+
Tests that depend on these APIs are currently ported without the experimental test cases (marked
127+
as "Partial" in the status column) or not ported at all. To fully support them, the CTS will need:
128+
129+
1. A mechanism for compiling addons with experimental API access (either from updated
130+
`node-api-headers`, CTS-provided forward declarations or copies of headers from the Node.js main repository)
131+
2. A way for implementors to declare which experimental features their runtime supports
132+
3. Conditional test execution that skips experimental assertions on runtimes that don't support them
133+
134+
See [#26](https://github.com/nodejs/node-api-cts/issues/26) for the full design discussion.
135+
109136
## Special Considerations
110137

111138
### `node_api_post_finalizer` (`6_object_wrap`, `test_finalizer`)

0 commit comments

Comments
 (0)