From e7ab552c747512b68e599bc33670911a1ba20e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 25 Apr 2026 23:31:20 +0200 Subject: [PATCH] chore: extract napiVersion into its own harness module Co-Authored-By: Claude Opus 4.6 --- implementors/node/features.js | 2 -- implementors/node/napi-version.js | 1 + implementors/node/tests.ts | 8 ++++++++ tests/harness/napi-version.js | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 implementors/node/napi-version.js create mode 100644 tests/harness/napi-version.js diff --git a/implementors/node/features.js b/implementors/node/features.js index 27286f8..b83da9e 100644 --- a/implementors/node/features.js +++ b/implementors/node/features.js @@ -8,8 +8,6 @@ globalThis.experimentalFeatures = { postFinalizer: true, }; -globalThis.napiVersion = Number(process.versions.napi); - globalThis.skipTest = () => { process.exit(0); }; diff --git a/implementors/node/napi-version.js b/implementors/node/napi-version.js new file mode 100644 index 0000000..a6f518d --- /dev/null +++ b/implementors/node/napi-version.js @@ -0,0 +1 @@ +globalThis.napiVersion = Number(process.versions.napi); diff --git a/implementors/node/tests.ts b/implementors/node/tests.ts index d4f8b2c..26e6a57 100644 --- a/implementors/node/tests.ts +++ b/implementors/node/tests.ts @@ -40,6 +40,12 @@ const MUST_CALL_MODULE_PATH = path.join( "node", "must-call.js" ); +const NAPI_VERSION_MODULE_PATH = path.join( + ROOT_PATH, + "implementors", + "node", + "napi-version.js" +); export function listDirectoryEntries(dir: string) { const entries = fs.readdirSync(dir, { withFileTypes: true }); @@ -80,6 +86,8 @@ export function runFileInSubprocess( "file://" + GC_MODULE_PATH, "--import", "file://" + MUST_CALL_MODULE_PATH, + "--import", + "file://" + NAPI_VERSION_MODULE_PATH, filePath, ], { cwd } diff --git a/tests/harness/napi-version.js b/tests/harness/napi-version.js new file mode 100644 index 0000000..78c792d --- /dev/null +++ b/tests/harness/napi-version.js @@ -0,0 +1,6 @@ +'use strict'; + +// napiVersion is a positive integer +if (typeof napiVersion !== 'number' || napiVersion < 1 || !Number.isInteger(napiVersion)) { + throw new Error('Expected a global napiVersion that is a positive integer'); +}