Skip to content

Commit 5b361aa

Browse files
committed
skip the test if napi version < 10
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
1 parent d6d9389 commit 5b361aa

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default defineConfig([
1717
mustNotCall: "readonly",
1818
gcUntil: "readonly",
1919
experimentalFeatures: "readonly",
20+
napiVersion: "readonly",
21+
skipTest: "readonly",
2022
},
2123
},
2224
rules: {

implementors/node/process.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const napiVersion = Number(process.versions.napi);
2+
3+
const skipTest = () => {
4+
process.exit(0);
5+
};
6+
7+
Object.assign(globalThis, { napiVersion, skipTest });

implementors/node/tests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const GC_MODULE_PATH = path.join(
3434
"node",
3535
"gc.js"
3636
);
37+
const PROCESS_MODULE_PATH = path.join(
38+
ROOT_PATH,
39+
"implementors",
40+
"node",
41+
"process.js"
42+
);
3743
const MUST_CALL_MODULE_PATH = path.join(
3844
ROOT_PATH,
3945
"implementors",
@@ -79,6 +85,8 @@ export function runFileInSubprocess(
7985
"--import",
8086
"file://" + GC_MODULE_PATH,
8187
"--import",
88+
"file://" + PROCESS_MODULE_PATH,
89+
"--import",
8290
"file://" + MUST_CALL_MODULE_PATH,
8391
filePath,
8492
],

tests/js-native-api/test_string/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
"use strict";
22

3+
// test_string addon requires Node-API version >= 10
4+
// (node_api_create_external_string_latin1/utf16).
5+
// Node-API 10 is supported in Node.js >= 22.14.0 and >= 23.6.0.
6+
if (Number(napiVersion) < 10) {
7+
skipTest();
8+
}
9+
310
// Testing api calls for string
411
const test_string = loadAddon("test_string");
512
// The insufficient buffer test case allocates a buffer of size 4, including

tests/js-native-api/test_string/test_null.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
"use strict";
22

3+
// test_string addon requires Node-API version >= 10
4+
// (node_api_create_external_string_latin1/utf16).
5+
// Node-API 10 is supported in Node.js >= 22.14.0 and >= 23.6.0.
6+
if (Number(napiVersion) < 10) {
7+
skipTest();
8+
}
9+
310
// Test passing NULL to object-related Node-APIs.
411
const { testNull } = loadAddon("test_string");
512

0 commit comments

Comments
 (0)