test: move tick.js from test/async-hooks to test/common

PR-URL: https://github.com/nodejs/node/pull/23551
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Artur Hayrapetyan 2018-10-12 10:35:08 -07:00 committed by Daniel Bevenius
parent 98d1d53b20
commit 2a1492a00d
25 changed files with 29 additions and 33 deletions

View File

@ -7,7 +7,7 @@ if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const crypto = require('crypto');

View File

@ -7,7 +7,7 @@ if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const crypto = require('crypto');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const async_hooks = require('async_hooks');
const { AsyncResource } = async_hooks;

View File

@ -85,7 +85,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const initHooks = require('./init-hooks');
const tick = require('./tick');
const tick = require('../common/tick');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dns = require('dns');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dns = require('dns');

View File

@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -5,7 +5,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const spawn = require('child_process').spawn;

View File

@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dns = require('dns');

View File

@ -6,7 +6,7 @@ if (!common.hasIPv6)
common.skip('IPv6 support required');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const net = require('net');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const TIMEOUT = common.platformTimeout(100);

View File

@ -8,7 +8,7 @@ const assert = require('assert');
const fixtures = require('../common/fixtures');
const tls = require('tls');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -4,7 +4,7 @@ const common = require('../common');
const assert = require('assert');
// general hook test setup
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -4,7 +4,7 @@ const common = require('../common');
const assert = require('assert');
// general hook test setup
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

View File

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const tick = require('../common/tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dgram = require('dgram');

View File

@ -13,6 +13,7 @@ This directory contains modules used to test the Node.js implementation.
* [Heap dump checker module](#heap-dump-checker-module)
* [HTTP2 module](#http2-module)
* [Internet module](#internet-module)
* [tick module](#tick-module)
* [tmpdir module](#tmpdir-module)
* [WPT module](#wpt-module)
@ -744,6 +745,11 @@ a full `setImmediate()` invocation passes.
should not be in scope when `listener.ongc()` is created.
## tick Module
The `tick` module provides a helper function that can be used to call a callback
after a given number of event loop "ticks".
## tmpdir Module
The `tmpdir` module supports the use of a temporary directory for testing.

View File

@ -6,6 +6,7 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
const makeDuplexPair = require('../common/duplexpair');
const tick = require('../common/tick');
// This tests that running garbage collection while an Http2Session has
// a write *scheduled*, it will survive that garbage collection.
@ -25,8 +26,3 @@ const makeDuplexPair = require('../common/duplexpair');
global.gc();
});
}
function tick(n, cb) {
if (n--) setImmediate(tick, n, cb);
else cb();
}

View File

@ -5,6 +5,7 @@ const common = require('../common');
const assert = require('assert');
const util = require('util');
const { MessageChannel } = require('worker_threads');
const tick = require('../common/tick');
const { port1, port2 } = new MessageChannel();
@ -42,10 +43,3 @@ port2.onmessage = common.mustCall((message) => {
});
});
port1.postMessage(2);
function tick(n, cb) {
if (n > 0)
setImmediate(() => tick(n - 1, cb));
else
cb();
}