Skip to content

Commit

Permalink
test: move tick.js from test/async-hooks to test/common
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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>
  • Loading branch information
arur authored and MylesBorins committed May 16, 2019
1 parent 16478de commit 5d86e63
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/async-hooks/test-crypto-pbkdf2.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-crypto-randomBytes.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-embedder.api.async-resource.js
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-enable-disable.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-fseventwrap.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-fsreqwrap-access.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-fsreqwrap-readFile.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-getaddrinforeqwrap.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-getnameinforeqwrap.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-httpparser.request.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-httpparser.response.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-immediate.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-pipeconnectwrap.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-pipewrap.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-querywrap.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-tcpwrap.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-timers.setTimeout.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-tlswrap.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-ttywrap.readstream.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-ttywrap.writestream.js
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-udpwrap.js
Expand Up @@ -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');
Expand Down
6 changes: 6 additions & 0 deletions test/common/README.md
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions test/parallel/test-http2-session-gc-while-write-scheduled.js
Expand Up @@ -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.
Expand All @@ -25,8 +26,3 @@ const makeDuplexPair = require('../common/duplexpair');
global.gc();
});
}

function tick(n, cb) {
if (n--) setImmediate(tick, n, cb);
else cb();
}
8 changes: 1 addition & 7 deletions test/parallel/test-worker-message-port-transfer-self.js
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
}

0 comments on commit 5d86e63

Please sign in to comment.