feat: extend harness with assert methods, gcUntil, and --expose-gc#27
Conversation
2e0313d to
c0c854d
Compare
| function(add_node_api_cts_addon ADDON_NAME SRC) | ||
| add_library(${ADDON_NAME} SHARED ${SRC}) | ||
| function(add_node_api_cts_addon ADDON_NAME) | ||
| add_library(${ADDON_NAME} SHARED ${ARGN}) |
There was a problem hiding this comment.
See https://cmake.org/cmake/help/latest/command/function.html#arguments for details on the ARGN variable.
| const assert = (value, message) => { | ||
| ok(value, message); | ||
| }; | ||
| const assert = Object.assign( |
There was a problem hiding this comment.
Non-blocking: I would prefer avoiding the assert() and assert.<method> style in this harness. We could update test cases to use proper asserts like assert.strictEqual whenever possible.
There was a problem hiding this comment.
That was my initial thought as well (which is why I didn't add it initially).
I realised later as I was porting tests that it's probably more important that the tests are ported as close to their original source as possible - to minimise the risk of loosing coverage. With these helpers it's more obvious that we're actually testing the same as the Node.js test suite.
I suggest we keep this as is for now and when we have more tests ported and ideally multiple implementors running these tests we can start refactoring them in isolation.
How does that plan sound to you?
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>
c0c854d to
2b4c2df
Compare
Summary
assertglobal with.ok,.strictEqual,.notStrictEqual,.deepStrictEqual, and.throwsmethodsgcUntil(name, condition)global for finalizer testing, with--expose-gcflagCMakeLists.txtto support multi-source addons viaARGNTest plan
npm run node:test— all 8 tests pass (3 harness + 1 existing test)🤖 Generated with Claude Code