Skip to content

Commit 2e9d32f

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 1d1e3f0 commit 2e9d32f

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
@@ -22,36 +22,36 @@ Tests covering the engine-specific part of Node-API, defined in `js_native_api.h
2222
| Directory | Status | Difficulty |
2323
|---|---|---|
2424
| `2_function_arguments` | Ported ||
25-
| `3_callbacks` | Not ported | Easy |
26-
| `4_object_factory` | Not ported | Easy |
27-
| `5_function_factory` | Not ported | Easy |
25+
| `3_callbacks` | Ported | Easy |
26+
| `4_object_factory` | Ported | Easy |
27+
| `5_function_factory` | Ported | Easy |
2828
| `6_object_wrap` | Not ported | Medium |
29-
| `7_factory_wrap` | Not ported | Easy |
30-
| `8_passing_wrapped` | Not ported | Easy |
31-
| `test_array` | Not ported | Easy |
32-
| `test_bigint` | Not ported | Easy |
29+
| `7_factory_wrap` | Ported | Easy |
30+
| `8_passing_wrapped` | Ported | Easy |
31+
| `test_array` | Ported | Easy |
32+
| `test_bigint` | Ported | Easy |
3333
| `test_cannot_run_js` | Not ported | Medium |
3434
| `test_constructor` | Not ported | Medium |
3535
| `test_conversions` | Not ported | Medium |
36-
| `test_dataview` | Not ported | Easy |
37-
| `test_date` | Not ported | Easy |
36+
| `test_dataview` | Partial | Easy |
37+
| `test_date` | Ported | Easy |
3838
| `test_error` | Not ported | Medium |
3939
| `test_exception` | Not ported | Medium |
4040
| `test_finalizer` | Not ported | Medium |
4141
| `test_function` | Not ported | Medium |
4242
| `test_general` | Not ported | Hard |
43-
| `test_handle_scope` | Not ported | Easy |
44-
| `test_instance_data` | Not ported | Easy |
45-
| `test_new_target` | Not ported | Easy |
46-
| `test_number` | Not ported | Easy |
43+
| `test_handle_scope` | Ported | Easy |
44+
| `test_instance_data` | Ported | Easy |
45+
| `test_new_target` | Ported | Easy |
46+
| `test_number` | Ported | Easy |
4747
| `test_object` | Not ported | Hard |
48-
| `test_promise` | Not ported | Easy |
49-
| `test_properties` | Not ported | Easy |
48+
| `test_promise` | Ported | Easy |
49+
| `test_properties` | Ported | Easy |
5050
| `test_reference` | Not ported | Medium |
51-
| `test_reference_double_free` | Not ported | Easy |
51+
| `test_reference_double_free` | Ported | Easy |
5252
| `test_sharedarraybuffer` | Not ported | Medium |
5353
| `test_string` | Not ported | Medium |
54-
| `test_symbol` | Not ported | Easy |
54+
| `test_symbol` | Ported | Easy |
5555
| `test_typedarray` | Not ported | Medium |
5656

5757
## Runtime-specific (`node-api`)
@@ -87,6 +87,33 @@ Tests covering the runtime-specific part of Node-API, defined in `node_api.h`.
8787
| `test_worker_terminate` | Not ported | Hard |
8888
| `test_worker_terminate_finalization` | Not ported | Hard |
8989

90+
## Experimental Node-API Features
91+
92+
Several tests in the upstream Node.js repository use experimental APIs that are guarded behind
93+
`#ifdef NAPI_EXPERIMENTAL` in Node.js's `js_native_api.h`. The `node-api-headers` package (which
94+
the CTS uses for compilation) does not currently include any of these experimental API declarations.
95+
96+
When `NAPI_EXPERIMENTAL` is defined in Node.js, `NAPI_VERSION` is set to
97+
`NAPI_VERSION_EXPERIMENTAL (2147483647)`. The `NAPI_MODULE` macro exports this version, and the
98+
runtime uses it to decide whether to enable experimental behavior for that addon.
99+
100+
| Feature macro | APIs | Used by |
101+
|---|---|---|
102+
| `NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER` | `node_api_is_sharedarraybuffer`, `node_api_create_sharedarraybuffer` | `test_dataview`, `test_sharedarraybuffer` |
103+
| `NODE_API_EXPERIMENTAL_HAS_CREATE_OBJECT_WITH_PROPERTIES` | `node_api_create_object_with_properties` | `test_object` |
104+
| `NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE` | `node_api_set_prototype` | `test_general` |
105+
| `NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER` | `node_api_post_finalizer` | `test_general`, `test_finalizer`, `6_object_wrap` |
106+
107+
Tests that depend on these APIs are currently ported without the experimental test cases (marked
108+
as "Partial" in the status column) or not ported at all. To fully support them, the CTS will need:
109+
110+
1. A mechanism for compiling addons with experimental API access (either from updated
111+
`node-api-headers`, CTS-provided forward declarations or copies of headers from the Node.js main repository)
112+
2. A way for implementors to declare which experimental features their runtime supports
113+
3. Conditional test execution that skips experimental assertions on runtimes that don't support them
114+
115+
See [#26](https://github.com/nodejs/node-api-cts/issues/26) for the full design discussion.
116+
90117
## Special Considerations
91118

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

0 commit comments

Comments
 (0)