feat: port test_cannot_run_js to CTS#28
Draft
kraenhansen wants to merge 6 commits intonodejs:mainfrom
Draft
Conversation
Enumerates all 58 test directories from Node.js's test/js-native-api and test/node-api, rates each by porting difficulty (Easy/Medium/Hard), and documents special considerations for tests with deep runtime dependencies (libuv, worker threads, SEA, node_api_post_finalizer, etc.). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the following to the Node.js implementor and harness in preparation for porting the easy js-native-api tests: - assert.js: expose assert.ok, .strictEqual, .notStrictEqual, .deepStrictEqual, and .throws as methods on the global assert object - gc.js: new module providing a global gcUntil(name, condition) helper that drives GC until a condition is met (needed for finalizer tests) - tests.ts: inject --expose-gc and gc.js into every test subprocess - CMakeLists.txt: broaden add_node_api_cts_addon() to accept multiple source files via ARGN (needed for multi-file addons) - tests/harness/assert.js: exercise all new assert methods - tests/harness/gc.js: exercise gcUntil pass and failure paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port all "Easy" difficulty engine-specific tests from Node.js: 3_callbacks, 4_object_factory, 5_function_factory, 7_factory_wrap, 8_passing_wrapped, test_array, test_bigint, test_dataview, test_date, test_handle_scope, test_instance_data, test_new_target, test_number, test_promise, test_properties, test_reference_double_free, test_symbol. C/C++ sources are copied from Node.js with minimal changes (entry_point.h macro). JS tests are adapted to use CTS globals (loadAddon, assert, gcUntil) instead of Node.js test harness (common.js, require). test_dataview: removed SharedArrayBuffer tests that depend on experimental node_api_is_sharedarraybuffer API (not in stable node-api-headers). Also updates node-api-headers from 1.7.0 to 1.8.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 nodejs#26. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Builds two addons from the same C source with different NAPI_VERSION defines (10 and 9) to verify that finalizers attempting to access JS during shutdown receive napi_cannot_run_js or napi_pending_exception (respectively), or napi_ok if the event loop is still running. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
This fails on Node v20, we might want to just remove that from the test matrix as active support ended 22 Oct 2024? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR is stacked on #25 and should not be reviewed or merged until that PR lands.
Summary
test_cannot_run_jsfromnode/test/js-native-api/to the CTStest_cannot_run_jswithNAPI_VERSION=10,test_pending_exceptionwithNAPI_VERSION=9) to cover both code paths in the finalizernapi_get_named_propertyreturnsnapi_cannot_run_js(v10+),napi_pending_exception(v9), ornapi_okif the event loop is still runningTest plan
npm run addons:configure && npm run addons:build— both addons compile cleanlynpm run node:test— all 48 tests pass, includingtest_cannot_run_js🤖 Generated with Claude Code