| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ let after = 0; | |||
| 17 | 17 | let destroy = 0; | |
| 18 | 18 | ||
| 19 | 19 | async_hooks.createHook({ | |
| 20 | - init(id, type, triggerAsyncId, resource) { | ||
| 20 | + init: common.mustCall((id, type, triggerAsyncId, resource) => { | ||
| 21 | 21 | assert.strictEqual(typeof id, 'number'); | |
| 22 | 22 | assert.strictEqual(typeof resource, 'object'); | |
| 23 | 23 | assert(id > 1); | |
@@ -26,7 +26,7 @@ async_hooks.createHook({ | |||
| 26 | 26 | assert.strictEqual(triggerAsyncId, expectedTriggerId); | |
| 27 | 27 | bindingUids.push(id); | |
| 28 | 28 | } | |
| 29 | - }, | ||
| 29 | + }, 7), | ||
| 30 | 30 | ||
| 31 | 31 | before(id) { | |
| 32 | 32 | if (bindingUids.includes(id)) before++; | |
@@ -48,8 +48,11 @@ for (const call of [binding.callViaFunction, | |||
| 48 | 48 | let uid; | |
| 49 | 49 | const object = { | |
| 50 | 50 | methöd(arg) { | |
| 51 | + // eslint-disable-next-line node-core/must-call-assert | ||
| 51 | 52 | assert.strictEqual(this, object); | |
| 53 | + // eslint-disable-next-line node-core/must-call-assert | ||
| 52 | 54 | assert.strictEqual(arg, 42); | |
| 55 | + // eslint-disable-next-line node-core/must-call-assert | ||
| 53 | 56 | assert.strictEqual(async_hooks.executionAsyncId(), uid); | |
| 54 | 57 | return 'baz'; | |
| 55 | 58 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ for (let i = 0; i < count; ++i) { | |||
| 23 | 23 | ||
| 24 | 24 | globalThis.gc(); | |
| 25 | 25 | ||
| 26 | - setTimeout(async function() { | ||
| 26 | + setTimeout(common.mustCall(() => (async function() { | ||
| 27 | 27 | // GC should have invoked Trace() on at least some of the CppGCed objects, | |
| 28 | 28 | // but they should all be alive at this point. | |
| 29 | 29 | assert.strictEqual(states[kDestructCount], 0); | |
@@ -48,4 +48,4 @@ setTimeout(async function() { | |||
| 48 | 48 | 'All old CppGCed are destroyed', | |
| 49 | 49 | () => states[kDestructCount] === count * 2, | |
| 50 | 50 | ); | |
| 51 | - }, 1); | ||
| 51 | + })().then(common.mustCall())), 1); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,11 +71,11 @@ assert.throws(() => { | |||
| 71 | 71 | if (arg === 1) { | |
| 72 | 72 | // The tests are first run on bootstrap during LoadEnvironment() in | |
| 73 | 73 | // src/node.cc. Now run the tests through node::MakeCallback(). | |
| 74 | - setImmediate(() => { | ||
| 74 | + setImmediate(common.mustCall(() => { | ||
| 75 | 75 | makeCallback({}, common.mustCall(() => { | |
| 76 | 76 | verifyExecutionOrder(2); | |
| 77 | 77 | })); | |
| 78 | - }); | ||
| 78 | + })); | ||
| 79 | 79 | } else if (arg === 2) { | |
| 80 | 80 | // Make sure there are no conflicts using node::MakeCallback() | |
| 81 | 81 | // within timers. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,37 +7,11 @@ const assert = require('assert'); | |||
| 7 | 7 | ||
| 8 | 8 | const bindingPath = require.resolve(`./build/${common.buildType}/binding`); | |
| 9 | 9 | ||
| 10 | - const assertError = (error) => { | ||
| 11 | - assert(error instanceof Error); | ||
| 12 | - assert.strictEqual(error.code, 'ERR_DLOPEN_DISABLED'); | ||
| 13 | - assert.strictEqual( | ||
| 14 | - error.message, | ||
| 15 | - 'Cannot load native addon because loading addons is disabled.', | ||
| 16 | - ); | ||
| 17 | - }; | ||
| 18 | - | ||
| 19 | - { | ||
| 20 | - let threw = false; | ||
| 21 | - | ||
| 22 | - try { | ||
| 23 | - require(bindingPath); | ||
| 24 | - } catch (error) { | ||
| 25 | - assertError(error); | ||
| 26 | - threw = true; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - assert(threw); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - { | ||
| 33 | - let threw = false; | ||
| 34 | - | ||
| 35 | - try { | ||
| 36 | - process.dlopen({ exports: {} }, bindingPath); | ||
| 37 | - } catch (error) { | ||
| 38 | - assertError(error); | ||
| 39 | - threw = true; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - assert(threw); | ||
| 43 | - } | ||
| 10 | + assert.throws(() => require(bindingPath), { | ||
| 11 | + code: 'ERR_DLOPEN_DISABLED', | ||
| 12 | + message: 'Cannot load native addon because loading addons is disabled.', | ||
| 13 | + }); | ||
| 14 | + assert.throws(() => process.dlopen({ exports: {} }, bindingPath), { | ||
| 15 | + code: 'ERR_DLOPEN_DISABLED', | ||
| 16 | + message: 'Cannot load native addon because loading addons is disabled.', | ||
| 17 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,21 +9,21 @@ const { Worker } = require('worker_threads'); | |||
| 9 | 9 | ||
| 10 | 10 | const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`); | |
| 11 | 11 | ||
| 12 | - const assertError = (error) => { | ||
| 12 | + const assertError = common.mustCall((error) => { | ||
| 13 | 13 | assert.strictEqual(error.code, 'ERR_DLOPEN_DISABLED'); | |
| 14 | 14 | assert.strictEqual( | |
| 15 | 15 | error.message, | |
| 16 | 16 | 'Cannot load native addon because loading addons is disabled.', | |
| 17 | 17 | ); | |
| 18 | - }; | ||
| 18 | + }, 4); | ||
| 19 | 19 | ||
| 20 | 20 | { | |
| 21 | 21 | // Flags should be inherited | |
| 22 | 22 | const worker = new Worker(`require(${JSON.stringify(binding)})`, { | |
| 23 | 23 | eval: true, | |
| 24 | 24 | }); | |
| 25 | 25 | ||
| 26 | - worker.on('error', common.mustCall(assertError)); | ||
| 26 | + worker.on('error', assertError); | ||
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | 29 | { | |
@@ -35,7 +35,7 @@ const assertError = (error) => { | |||
| 35 | 35 | }, | |
| 36 | 36 | ); | |
| 37 | 37 | ||
| 38 | - worker.on('error', common.mustCall(assertError)); | ||
| 38 | + worker.on('error', assertError); | ||
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | 41 | { | |
@@ -45,7 +45,7 @@ const assertError = (error) => { | |||
| 45 | 45 | execArgv: ['--no-addons'], | |
| 46 | 46 | }); | |
| 47 | 47 | ||
| 48 | - worker.on('error', common.mustCall(assertError)); | ||
| 48 | + worker.on('error', assertError); | ||
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | 51 | { | |
@@ -55,5 +55,5 @@ const assertError = (error) => { | |||
| 55 | 55 | execArgv: [], | |
| 56 | 56 | }); | |
| 57 | 57 | ||
| 58 | - worker.on('error', common.mustCall(assertError)); | ||
| 58 | + worker.on('error', assertError); | ||
| 59 | 59 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,37 +7,11 @@ const assert = require('assert'); | |||
| 7 | 7 | ||
| 8 | 8 | const bindingPath = require.resolve(`./build/${common.buildType}/binding`); | |
| 9 | 9 | ||
| 10 | - const assertError = (error) => { | ||
| 11 | - assert(error instanceof Error); | ||
| 12 | - assert.strictEqual(error.code, 'ERR_DLOPEN_DISABLED'); | ||
| 13 | - assert.strictEqual( | ||
| 14 | - error.message, | ||
| 15 | - 'Cannot load native addon because loading addons is disabled.', | ||
| 16 | - ); | ||
| 17 | - }; | ||
| 18 | - | ||
| 19 | - { | ||
| 20 | - let threw = false; | ||
| 21 | - | ||
| 22 | - try { | ||
| 23 | - require(bindingPath); | ||
| 24 | - } catch (error) { | ||
| 25 | - assertError(error); | ||
| 26 | - threw = true; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - assert(threw); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - { | ||
| 33 | - let threw = false; | ||
| 34 | - | ||
| 35 | - try { | ||
| 36 | - process.dlopen({ exports: {} }, bindingPath); | ||
| 37 | - } catch (error) { | ||
| 38 | - assertError(error); | ||
| 39 | - threw = true; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - assert(threw); | ||
| 43 | - } | ||
| 10 | + assert.throws(() => require(bindingPath), { | ||
| 11 | + code: 'ERR_DLOPEN_DISABLED', | ||
| 12 | + message: 'Cannot load native addon because loading addons is disabled.', | ||
| 13 | + }); | ||
| 14 | + assert.throws(() => process.dlopen({ exports: {} }, bindingPath), { | ||
| 15 | + code: 'ERR_DLOPEN_DISABLED', | ||
| 16 | + message: 'Cannot load native addon because loading addons is disabled.', | ||
| 17 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,6 @@ const binding = require(`./build/${common.buildType}/binding`); | |||
| 6 | 6 | ||
| 7 | 7 | binding.run(); | |
| 8 | 8 | global.gc(); | |
| 9 | - setImmediate(() => { | ||
| 9 | + setImmediate(common.mustCall(() => { | ||
| 10 | 10 | assert.strictEqual(binding.isAlive(), 0); | |
| 11 | - }); | ||
| 11 | + })); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,13 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../../common'); | ||
| 2 | + const common = require('../../common'); | ||
| 3 | 3 | const path = require('path'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | ||
| 6 | 6 | // This is a subtest of symlinked-module/test.js. This is not | |
| 7 | 7 | // intended to be run directly. | |
| 8 | 8 | ||
| 9 | - module.exports.test = function test(bindingDir) { | ||
| 9 | + module.exports.test = common.mustCall(function test(bindingDir) { | ||
| 10 | 10 | const mod = require(path.join(bindingDir, 'binding.node')); | |
| 11 | 11 | assert.notStrictEqual(mod, null); | |
| 12 | 12 | assert.strictEqual(mod.hello(), 'world'); | |
| 13 | - }; | ||
| 13 | + }, require.main === module ? 0 : 2); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -156,7 +156,21 @@ export default [ | |||
| 156 | 156 | }, | |
| 157 | 157 | { | |
| 158 | 158 | files: [ | |
| 159 | - 'test/{async-hooks,benchmark,cctest,client-proxy,message,module-hooks,node-api,pummel,pseudo-tty,v8-updates,wasi}/**/*.{js,mjs,cjs}', | ||
| 159 | + `test/{${[ | ||
| 160 | + 'abort', | ||
| 161 | + 'addons', | ||
| 162 | + 'async-hooks', | ||
| 163 | + 'benchmark', | ||
| 164 | + 'cctest', | ||
| 165 | + 'client-proxy', | ||
| 166 | + 'message', | ||
| 167 | + 'module-hooks', | ||
| 168 | + 'node-api', | ||
| 169 | + 'pummel', | ||
| 170 | + 'pseudo-tty', | ||
| 171 | + 'v8-updates', | ||
| 172 | + 'wasi', | ||
| 173 | + ].join(',')}}/**/*.{js,mjs,cjs}`, | ||
| 160 | 174 | ], | |
| 161 | 175 | rules: { | |
| 162 | 176 | 'node-core/must-call-assert': 'error', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments