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: #23551
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
arur authored and jasnell committed Oct 17, 2018
1 parent 39377bc commit 1471023
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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-fsreqcallback-access.js
Original file line number Diff line number Diff line change
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-fsreqcallback-readFile.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-httpparser.response.js
Original file line number Diff line number Diff line change
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');

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-immediate.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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').spawn;
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-querywrap.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1471023

Please sign in to comment.