Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bb1e8a6
deps: cherry-pick 6989b3f6d7 from V8 upstream
TimothyGu May 18, 2018
0c43ea4
deps: Upgrade node-inspect to 1.11.5
May 31, 2018
d388282
doc: add error check to fs example
evanlucas Feb 9, 2018
0b2d35c
test: add useful info to error msg and refactor
chinhuang007 Feb 2, 2018
edd8b2f
test: add crypto check to test-benchmark-tls
danbev Feb 12, 2018
bc66d4e
test: add multiline repl input regression test
cjihrig Feb 11, 2018
b01e470
doc: update crypo Certficate class.
antoine-amara Feb 11, 2018
a66434f
test: add lib path env when node_shared=true
yhwang Feb 2, 2018
92a90d1
test: wrap countdown callback in common.mustCall
Bamieh Nov 21, 2017
6a8c182
doc: remove extra space in README.md
Feb 16, 2018
7fbc6a4
test: try to connect after server was closed
Leko Jan 19, 2018
06b6507
test: reduce benchmark test run time
juggernaut451 Feb 14, 2018
077fb0a
test: make tls test more rigorous
bnoordhuis Feb 15, 2018
0ef0dbc
test: refactor of test-tls-over-http-tunnel
juggernaut451 Feb 14, 2018
8345f3c
test: refactor parallel/test-tls-addca
juggernaut451 Feb 15, 2018
4070782
test,benchmark,doc: enable dot-notation rule
BridgeAR Feb 13, 2018
8651766
doc: note that linting is required in releases.md
gibfahn Feb 14, 2018
b4fa857
doc: activate `no-multiple-empty-lines` rule
BridgeAR Feb 13, 2018
bf1ca7e
src: allow --perf-(basic-)?prof in NODE_OPTIONS
Leko Dec 11, 2017
c1c6253
crypto: allow passing null as IV unless required
tniessen Feb 7, 2018
c3a96ba
async_hooks: rename PromiseWrap.parentId
ofrobots Feb 8, 2018
a2e4940
fs: support as and as+ flags in stringToFlags()
Feb 15, 2018
5975c06
doc: add missing metadata for fs.open
tniessen Mar 25, 2018
bcaba81
tls: expose Finished messages in TLSSocket
codedot Mar 2, 2018
ae6e4bd
fs,net: emit 'ready' for fs streams and sockets
sameer-coder Mar 17, 2018
d3cc97b
deps: backport 804a693 from upstream V8
Jul 17, 2018
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
Prev Previous commit
Next Next commit
test: wrap countdown callback in common.mustCall
This adds a implicit common.mustCall to the callback provided to
the countdown.

PR-URL: #18506
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Bamieh authored and MylesBorins committed Aug 7, 2018
commit 92a90d1b5a9b2f80e3f19648277d35c788d5cc28
2 changes: 1 addition & 1 deletion test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Synchronous version of `spawnPwd`.
The `Countdown` module provides a simple countdown mechanism for tests that
require a particular action to be taken after a given number of completed
tasks (for instance, shutting down an HTTP server after a specific number of
requests).
requests). The Countdown will fail the test if the remainder did not reach 0.

<!-- eslint-disable strict, required-modules -->
```js
Expand Down
3 changes: 2 additions & 1 deletion test/common/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
const assert = require('assert');
const kLimit = Symbol('limit');
const kCallback = Symbol('callback');
const common = require('./');

class Countdown {
constructor(limit, cb) {
assert.strictEqual(typeof limit, 'number');
assert.strictEqual(typeof cb, 'function');
this[kLimit] = limit;
this[kCallback] = cb;
this[kCallback] = common.mustCall(cb);
}

dec() {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/failcounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const Countdown = require('../common/countdown');
new Countdown(2, () => {});
22 changes: 20 additions & 2 deletions test/parallel/test-common-countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@
const common = require('../common');
const assert = require('assert');
const Countdown = require('../common/countdown');
const fixtures = require('../common/fixtures');
const { execFile } = require('child_process');

let done = '';

const countdown = new Countdown(2, common.mustCall(() => done = true));
const countdown = new Countdown(2, () => done = true);
assert.strictEqual(countdown.remaining, 2);
countdown.dec();
assert.strictEqual(countdown.remaining, 1);
countdown.dec();
assert.strictEqual(countdown.remaining, 0);
assert.strictEqual(done, true);

const failFixtures = [
[
fixtures.path('failcounter.js'),
'Mismatched <anonymous> function calls. Expected exactly 1, actual 0.',
]
];

for (const p of failFixtures) {
const [file, expected] = p;
execFile(process.argv[0], [file], common.mustCall((ex, stdout, stderr) => {
assert.ok(ex);
assert.strictEqual(stderr, '');
const firstLine = stdout.split('\n').shift();
assert.strictEqual(firstLine, expected);
}));
}
2 changes: 1 addition & 1 deletion test/parallel/test-http-after-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const server = http.createServer(common.mustCall((req, res) => {
setTimeout(() => res.end(req.url), 50);
}, 2));

const countdown = new Countdown(2, common.mustCall(() => server.close()));
const countdown = new Countdown(2, () => server.close());

server.on('connect', common.mustCall((req, socket) => {
socket.write('HTTP/1.1 200 Connection established\r\n\r\n');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-destroyed-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const server = http.createServer(common.mustCall((req, res) => {
assert(request1.socket.destroyed);
// assert not reusing the same socket, since it was destroyed.
assert.notStrictEqual(request1.socket, request2.socket);
const countdown = new Countdown(2, common.mustCall(() => server.close()));
const countdown = new Countdown(2, () => server.close());
request2.socket.on('close', common.mustCall(() => countdown.dec()));
response.on('end', common.mustCall(() => countdown.dec()));
response.resume();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-maxsockets-regress-4050.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const server = http.createServer(common.mustCall((req, res) => {
res.end('hello world');
}, 6));

const countdown = new Countdown(6, common.mustCall(() => server.close()));
const countdown = new Countdown(6, () => server.close());

function get(path, callback) {
return http.get({
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http-agent-maxsockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ function get(path, callback) {
}, callback);
}

const countdown = new Countdown(2, common.mustCall(() => {
const countdown = new Countdown(2, () => {
const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
assert.strictEqual(freepool.length, 2,
`expect keep 2 free sockets, but got ${freepool.length}`);
agent.destroy();
server.close();
}));
});

function dec() {
process.nextTick(() => countdown.dec());
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-client-abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Countdown = require('../common/countdown');

const N = 8;

const countdown = new Countdown(N, common.mustCall(() => server.close()));
const countdown = new Countdown(N, () => server.close());

const server = http.Server(common.mustCall((req, res) => {
res.writeHead(200);
Expand All @@ -37,9 +37,9 @@ const server = http.Server(common.mustCall((req, res) => {
server.listen(0, common.mustCall(() => {

const requests = [];
const reqCountdown = new Countdown(N, common.mustCall(() => {
const reqCountdown = new Countdown(N, () => {
requests.forEach((req) => req.abort());
}));
});

const options = { port: server.address().port };

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-client-parse-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const http = require('http');
const net = require('net');
const Countdown = require('../common/countdown');

const countdown = new Countdown(2, common.mustCall(() => server.close()));
const countdown = new Countdown(2, () => server.close());

const payloads = [
'HTTP/1.1 302 Object Moved\r\nContent-Length: 0\r\n\r\nhi world',
Expand Down
23 changes: 14 additions & 9 deletions test/parallel/test-http-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

'use strict';
require('../common');
const Countdown = require('../common/countdown');
const http = require('http');
const NUMBER_OF_EXCEPTIONS = 4;
const countdown = new Countdown(NUMBER_OF_EXCEPTIONS, () => {
process.exit(0);
});

const server = http.createServer(function(req, res) {
intentionally_not_defined(); // eslint-disable-line no-undef
Expand All @@ -30,16 +35,16 @@ const server = http.createServer(function(req, res) {
res.end();
});

function onUncaughtException(err) {
console.log(`Caught an exception: ${err}`);
if (err.name === 'AssertionError') throw err;
countdown.dec();
}

process.on('uncaughtException', onUncaughtException);

server.listen(0, function() {
for (let i = 0; i < 4; i += 1) {
for (let i = 0; i < NUMBER_OF_EXCEPTIONS; i += 1) {
http.get({ port: this.address().port, path: `/busy/${i}` });
}
});

let exception_count = 0;

process.on('uncaughtException', function(err) {
console.log(`Caught an exception: ${err}`);
if (err.name === 'AssertionError') throw err;
if (++exception_count === 4) process.exit(0);
});
4 changes: 2 additions & 2 deletions test/parallel/test-http2-no-more-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ server.listen(0, common.mustCall(() => {

assert.strictEqual(client.state.nextStreamID, nextID);

const countdown = new Countdown(2, common.mustCall(() => {
const countdown = new Countdown(2, () => {
server.close();
client.close();
}));
});

{
// This one will be ok
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-server-rst-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ server.on('stream', (stream, headers) => {
server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);

const countdown = new Countdown(tests.length, common.mustCall(() => {
const countdown = new Countdown(tests.length, () => {
client.close();
server.close();
}));
});

tests.forEach((test) => {
const req = client.request({
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-performanceobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0);
new PerformanceObserver(common.mustCall(callback, 3));

const countdown =
new Countdown(3, common.mustCall(() => {
new Countdown(3, () => {
observer.disconnect();
assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 1);
}));
});

function callback(list, obs) {
assert.strictEqual(obs, observer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const server = net.createServer(function onClient(client) {
});

server.listen(0, common.localhostIPv4, common.mustCall(() => {
const countdown = new Countdown(2, common.mustCall(() => server.close()));
const countdown = new Countdown(2, () => server.close());

{
const client = net.connect({ port: server.address().port });
Expand Down