Skip to content

port test_reference to CTS#47

Open
bavulapati wants to merge 10 commits intonodejs:mainfrom
bavulapati:feat/port-test-reference
Open

port test_reference to CTS#47
bavulapati wants to merge 10 commits intonodejs:mainfrom
bavulapati:feat/port-test-reference

Conversation

@bavulapati
Copy link
Copy Markdown
Contributor

ports
test_reference from the Node.js test suite to the CTS.

@bavulapati
Copy link
Copy Markdown
Contributor Author

@legendecas Can we run the tests again?

ports
[test_reference](https://github.com/nodejs/node/tree/main/test/js-native-api/test_reference)
from the Node.js test suite to the CTS.

Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
@bavulapati bavulapati force-pushed the feat/port-test-reference branch from e6591cc to 0d6c4b7 Compare April 7, 2026 06:16
Comment thread implementors/node/tests.ts Outdated
"--import",
"file://" + MUST_CALL_MODULE_PATH,
// test_finalizer needs this
"--force-node-api-uncaught-exceptions-policy",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need a way to run tests with and without this enabled? 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #60 to track that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag has been enabled by default, and it is a legacy Node.js bug. I don't think it is necessary to keep track of this flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the flag

@kraenhansen
Copy link
Copy Markdown
Member

Verification: Test code compared against upstream Node.js

I compared the test files in this PR against the upstream Node.js source at test/js-native-api/test_reference/.

C Files: Identical

  • test_reference.c — byte-for-byte identical to upstream
  • test_finalizer.c — byte-for-byte identical to upstream

JS Files: Only Expected Harness Adaptations

Both test.js and test_finalizer.js differ only in mechanical ways:

  1. Quote style — single quotes → double quotes (prettier)
  2. Imports replaced with CTS globalsrequire('assert'), require('../../common'), etc. replaced with loadAddon(), and CTS globals (assert, gc, gcUntil, mustCall)
  3. global.gc()gc() — uses CTS global directly
  4. process.on('uncaughtException', ...)onUncaughtException(...) — new CTS harness abstraction (in test_finalizer.js)
  5. Prettier formatting — trailing commas, multi-line reformatting

No test logic was added, removed, or altered. The port is faithful to upstream.

Comment on lines +1 to +3
const onUncaughtException = (cb) => {
process.on("uncaughtException", cb);
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again - unsure how we'd be implementing this in other implementors 🤔 But perhaps we'll just have to cross that bridge when we get there.

@@ -0,0 +1,23 @@
"use strict";
// Flags: --expose-gc --force-node-api-uncaught-exceptions-policy
Copy link
Copy Markdown
Member

@kraenhansen kraenhansen Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to wonder if we should add some file to the node implementor harness to track which test files needs what flags enabled when spawning the test's sub-process 🤔

Copy link
Copy Markdown
Member

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a harness test for onUncaughtException.

@bavulapati bavulapati requested a review from kraenhansen April 26, 2026 13:30
@@ -0,0 +1,168 @@
"use strict";
// Flags: --expose-gc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a V8 specific flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need any action item?
This flag is needed from my testing.
Do we need to document anything?
Oh! it is about #47 (comment)

Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
@bavulapati bavulapati requested a review from legendecas April 27, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

3 participants