diff options
author | James M Snell <jasnell@gmail.com> | 2018-08-21 13:38:59 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-08-24 10:32:09 -0700 |
commit | d495e40bf7c75c689df75b09ae1bf9a92f3eb584 (patch) | |
tree | e1616a74cf3ebb3062332fffe7d7c50766a825cb /test/common/README.md | |
parent | 3579ec4171734fea65e52d385594a35a40bcde8f (diff) | |
download | android-node-v8-d495e40bf7c75c689df75b09ae1bf9a92f3eb584.tar.gz android-node-v8-d495e40bf7c75c689df75b09ae1bf9a92f3eb584.tar.bz2 android-node-v8-d495e40bf7c75c689df75b09ae1bf9a92f3eb584.zip |
test: move common.onGC to individual module
Incrementally making `require('../common')` less of a monolith.
Move the `common.onGC()` utility to a separate standalone module
that is only imported when it's actually needed.
PR-URL: https://github.com/nodejs/node/pull/22446
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/common/README.md')
-rw-r--r-- | test/common/README.md | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/test/common/README.md b/test/common/README.md index 487c252af3..63d3b16361 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -296,21 +296,6 @@ otherwise. ### noWarnCode See `common.expectWarning()` for usage. -### onGC(target, listener) -* `target` [<Object>] -* `listener` [<Object>] - * `ongc` [<Function>] - -Installs a GC listener for the collection of `target`. - -This uses `async_hooks` for GC tracking. This means that it enables -`async_hooks` tracking, which may affect the test functionality. It also -means that between a `global.gc()` call and the listener being invoked -a full `setImmediate()` invocation passes. - -`listener` is an object to make it easier to use a closure; the target object -should not be in scope when `listener.ongc()` is created. - ### opensslCli * [<boolean>] @@ -759,6 +744,34 @@ via `NODE_TEST_*` environment variables. For example, to configure `internet.addresses.INET_HOST`, set the environment variable `NODE_TEST_INET_HOST` to a specified host. +## ongc Module + +The `ongc` module allows a garbage collection listener to be installed. The +module exports a single `onGC()` function. + +```js +require('../common'); +const onGC = require('../common/ongc'); + +onGC({}, { ongc() { console.log('collected'); } }); +``` + +### onGC(target, listener) +* `target` [<Object>] +* `listener` [<Object>] + * `ongc` [<Function>] + +Installs a GC listener for the collection of `target`. + +This uses `async_hooks` for GC tracking. This means that it enables +`async_hooks` tracking, which may affect the test functionality. It also +means that between a `global.gc()` call and the listener being invoked +a full `setImmediate()` invocation passes. + +`listener` is an object to make it easier to use a closure; the target object +should not be in scope when `listener.ongc()` is created. + + ## tmpdir Module The `tmpdir` module supports the use of a temporary directory for testing. |