Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v10.x backport] test: move tick.js from test/async-hooks to test/common #23780

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-fsreqwrap-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-fsreqwrap-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 @@ -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
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-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');
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-timerwrap.setInterval.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 = 1;
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-timerwrap.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
11 changes: 11 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,16 @@ 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".

### tick(x, cb)

* `x` [<number>] Number of event loop "ticks".
* `cb` [<Function>] A callback function.

## 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();
}