(resName)
| 20 | module.exports = common.runTest(test); |
| 21 | |
| 22 | function installAsyncHooksForTest (resName) { |
| 23 | return new Promise((resolve, reject) => { |
| 24 | let id; |
| 25 | const events = []; |
| 26 | /** |
| 27 | * TODO(legendecas): investigate why resolving & disabling hooks in |
| 28 | * destroy callback causing crash with case 'callbackscope.js'. |
| 29 | */ |
| 30 | let destroyed = false; |
| 31 | const hook = asyncHooks.createHook({ |
| 32 | init (asyncId, type, triggerAsyncId, resource) { |
| 33 | if (id === undefined && type === resName) { |
| 34 | id = asyncId; |
| 35 | events.push({ eventName: 'init', type, triggerAsyncId, resource }); |
| 36 | } |
| 37 | }, |
| 38 | before (asyncId) { |
| 39 | if (asyncId === id) { |
| 40 | events.push({ eventName: 'before' }); |
| 41 | } |
| 42 | }, |
| 43 | after (asyncId) { |
| 44 | if (asyncId === id) { |
| 45 | events.push({ eventName: 'after' }); |
| 46 | } |
| 47 | }, |
| 48 | destroy (asyncId) { |
| 49 | if (asyncId === id) { |
| 50 | events.push({ eventName: 'destroy' }); |
| 51 | destroyed = true; |
| 52 | } |
| 53 | } |
| 54 | }).enable(); |
| 55 | |
| 56 | const interval = setInterval(() => { |
| 57 | if (destroyed) { |
| 58 | hook.disable(); |
| 59 | clearInterval(interval); |
| 60 | resolve(events); |
| 61 | } |
| 62 | }, 10); |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | async function makeCallbackWithResource (binding) { |
| 67 | const hooks = installAsyncHooksForTest('async_context_test'); |
no outgoing calls
no test coverage detected