Skip to content

Commit 05aa3a1

Browse files
StefanStojanovictargos
authored andcommitted
test,win: split addon tests
PR-URL: #59805 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 0a87084 commit 05aa3a1

File tree

13 files changed

+53
-23
lines changed

13 files changed

+53
-23
lines changed
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'binding-export-default',
5+
'sources': [ 'binding-export-default.cc' ],
6+
'includes': ['../common.gypi'],
7+
},
8+
]
9+
}

β€Žtest/addons/esm-export/test-esm.mjsβ€Ž renamed to β€Žtest/addons/esm-export-default/test-esm.mjsβ€Ž

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,4 @@ export async function run() {
2424
assert.strictEqual(ns.default, ns['module.exports']);
2525
assert.strictEqual(ns.default.default(), 'hello world');
2626
}
27-
28-
// binding-export-primitive.node
29-
{
30-
const bindingPath = require.resolve(`./build/${buildType}/binding-export-primitive.node`);
31-
const ns = await import(pathToFileURL(bindingPath));
32-
33-
// As same as ESM-import-CJS, the default export is the value of `module.exports`.
34-
assert.strictEqual(ns.default, ns['module.exports']);
35-
assert.strictEqual(ns.default, 'hello world');
36-
}
3727
}
File renamed without changes.
File renamed without changes.

β€Žtest/addons/esm-export/binding.gypβ€Ž renamed to β€Žtest/addons/esm-export-primitive/binding.gypβ€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
'targets': [
3-
{
4-
'target_name': 'binding-export-default',
5-
'sources': [ 'binding-export-default.cc' ],
6-
'includes': ['../common.gypi'],
7-
},
83
{
94
'target_name': 'binding-export-primitive',
105
'sources': [ 'binding-export-primitive.cc' ],
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* This file is supposed to be loaded by `test-import.js` and `test-require.js`
3+
* to verify that `import('*.node')` is working properly either been loaded with
4+
* the ESM loader or the CJS loader.
5+
*/
6+
7+
import { buildType } from '../../common/index.mjs';
8+
import assert from 'node:assert';
9+
import { createRequire } from 'node:module';
10+
import { pathToFileURL } from 'node:url';
11+
12+
const require = createRequire(import.meta.url);
13+
14+
export async function run() {
15+
// binding-export-primitive.node
16+
{
17+
const bindingPath = require.resolve(`./build/${buildType}/binding-export-primitive.node`);
18+
const ns = await import(pathToFileURL(bindingPath));
19+
20+
// As same as ESM-import-CJS, the default export is the value of `module.exports`.
21+
assert.strictEqual(ns.default, ns['module.exports']);
22+
assert.strictEqual(ns.default, 'hello world');
23+
}
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Flags: --experimental-addon-modules
2+
'use strict';
3+
const common = require('../../common');
4+
5+
require('./test-esm.mjs')
6+
.run().then(common.mustCall());
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'binding',
5+
'sources': [ 'binding.cc' ],
6+
'includes': ['../common.gypi'],
7+
},
8+
]
9+
}

0 commit comments

Comments
Β (0)