Skip to content

Commit c6cf45e

Browse files
committed
split tests to separate v10 sub tests
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
1 parent 5b361aa commit c6cf45e

File tree

11 files changed

+352
-304
lines changed

11 files changed

+352
-304
lines changed

implementors/node/features.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ globalThis.experimentalFeatures = {
77
setPrototype: true,
88
postFinalizer: true,
99
};
10+
11+
globalThis.napiVersion = Number(process.versions.napi);
12+
13+
globalThis.skipTest = () => {
14+
process.exit(0);
15+
};

implementors/node/process.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

implementors/node/run-tests.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ import { listDirectoryEntries, runFileInSubprocess } from "./tests.ts";
66
const ROOT_PATH = path.resolve(import.meta.dirname, "..", "..");
77
const TESTS_ROOT_PATH = path.join(ROOT_PATH, "tests");
88

9-
const ASSERT_MODULE_PATH = path.join(
10-
ROOT_PATH,
11-
"implementors",
12-
"node",
13-
"assert.js"
14-
);
15-
const LOAD_ADDON_MODULE_PATH = path.join(
16-
ROOT_PATH,
17-
"implementors",
18-
"node",
19-
"load-addon.js"
20-
);
21-
229
async function populateSuite(
2310
testContext: TestContext,
2411
dir: string

implementors/node/tests.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ 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-
);
4337
const MUST_CALL_MODULE_PATH = path.join(
4438
ROOT_PATH,
4539
"implementors",
@@ -85,8 +79,6 @@ export function runFileInSubprocess(
8579
"--import",
8680
"file://" + GC_MODULE_PATH,
8781
"--import",
88-
"file://" + PROCESS_MODULE_PATH,
89-
"--import",
9082
"file://" + MUST_CALL_MODULE_PATH,
9183
filePath,
9284
],
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
add_node_api_cts_addon(test_string test_string.c test_null.c)
2-
# API like node_api_create_external_string_latin1 are available from NAPI_VERSION >= 10
3-
target_compile_definitions(test_string PRIVATE NAPI_VERSION=10)
2+
3+
# APIs like node_api_create_external_string_latin1 and
4+
# node_api_create_property_key_utf8 are available from NAPI_VERSION >= 10
5+
add_node_api_cts_addon(test_string_v10 test_string_v10.c)
6+
target_compile_definitions(test_string_v10 PRIVATE NAPI_VERSION=10)

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
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-
103
// Testing api calls for string
114
const test_string = loadAddon("test_string");
125
// The insufficient buffer test case allocates a buffer of size 4, including
@@ -44,10 +37,6 @@ const unicodeCases = [
4437
function testLatin1Cases(str) {
4538
assert.strictEqual(test_string.TestLatin1(str), str);
4639
assert.strictEqual(test_string.TestLatin1AutoLength(str), str);
47-
assert.strictEqual(test_string.TestLatin1External(str), str);
48-
assert.strictEqual(test_string.TestLatin1ExternalAutoLength(str), str);
49-
assert.strictEqual(test_string.TestPropertyKeyLatin1(str), str);
50-
assert.strictEqual(test_string.TestPropertyKeyLatin1AutoLength(str), str);
5140
assert.strictEqual(test_string.Latin1Length(str), str.length);
5241

5342
if (str !== "") {
@@ -63,12 +52,6 @@ function testUnicodeCases(str, utf8Length, utf8InsufficientIdx) {
6352
assert.strictEqual(test_string.TestUtf16(str), str);
6453
assert.strictEqual(test_string.TestUtf8AutoLength(str), str);
6554
assert.strictEqual(test_string.TestUtf16AutoLength(str), str);
66-
assert.strictEqual(test_string.TestUtf16External(str), str);
67-
assert.strictEqual(test_string.TestUtf16ExternalAutoLength(str), str);
68-
assert.strictEqual(test_string.TestPropertyKeyUtf8(str), str);
69-
assert.strictEqual(test_string.TestPropertyKeyUtf8AutoLength(str), str);
70-
assert.strictEqual(test_string.TestPropertyKeyUtf16(str), str);
71-
assert.strictEqual(test_string.TestPropertyKeyUtf16AutoLength(str), str);
7255
assert.strictEqual(test_string.Utf8Length(str), utf8Length);
7356
assert.strictEqual(test_string.Utf16Length(str), str.length);
7457

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
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-
103
// Test passing NULL to object-related Node-APIs.
114
const { testNull } = loadAddon("test_string");
125

0 commit comments

Comments
 (0)