Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
4d3e158
test,lib,benchmark: match function names
Trott Oct 15, 2016
2677b9b
deps: V8: fix debug backtrace for symbols
ofrobots Jan 11, 2017
47d18d4
deps: backport d800a65 from V8 upstream
MylesBorins Jun 20, 2016
83144af
deps: backport 7a88ff3 from V8 upstream
MylesBorins Jun 22, 2016
e0db108
deps: backport a715957 from V8 upstream
MylesBorins Jun 29, 2016
20bee0f
deps: update patch level in V8
MylesBorins Jan 12, 2017
504b01b
v8,src: expose statistics about heap spaces
bripkens Dec 29, 2015
1c81530
child_process: add shell option to spawn()
cjihrig Jan 8, 2016
12ede48
fs: add the fs.mkdtemp() function.
ralt Feb 24, 2016
2912da4
process: add `process.memoryUsage.external`
indutny Nov 12, 2016
6b66647
test: refactor test-net-keepalive.js
kmccmk9 Dec 1, 2016
821498e
test: check for error on invalid signal
mattcphillips Dec 1, 2016
25fea45
tools: add macosx-firwall script to avoid popups
danbev Dec 3, 2016
3bd7ab1
test: stream readableListening internal state
Dec 1, 2016
b302358
test: refactor test-handle-wrap-close-abort
Trott Dec 9, 2016
151cca6
process: add process.cpuUsage() - implementation, doc, tests
Apr 5, 2016
1a40f2d
tls, crypto: add ALPN Support
Apr 23, 2015
d706c0d
tls,crypto: move NPN protcol data to hidden value
Oct 26, 2015
43ee08f
test: fix alpn tests for openssl1.0.2h
May 3, 2016
15462eb
tls: copy the Buffer object before using
thefourtheye Aug 10, 2016
4341166
crypto: remove unnecessary variables of alpn/npn
shigeki Jan 16, 2017
2390fa9
test: refactor http pipelined socket test
Trott Dec 9, 2016
126d243
test: refactor assert.equal, update syntax to ES6
Dec 1, 2016
8109d61
test: refactor test-http-after-connect.js
larissayvette Dec 11, 2016
b4879f8
test: refactor test-fs-fsync
radelmann Dec 7, 2016
dccd5fd
test: refactor test-crypto-random
Trott Dec 12, 2016
494d236
test: use const/let and common.mustCall
outsideris Dec 1, 2016
2104124
test: cleanup test-stdout-close-catch.js
furnox Dec 1, 2016
6f8c901
test: refactor test-tls-ecdh-disable
Dec 1, 2016
a9ee489
win,msi: add required UIRef for localized strings
billti Oct 1, 2016
d5babe6
test: refactor test-timers-this
Trott Dec 17, 2016
5e9c6b5
doc: add Michaël Zasso to the CTC
targos Dec 21, 2016
3b7694f
test: add test-require-invalid-package
Dec 21, 2016
d559ba3
test: refactor test-net-reconnect-error
Dec 21, 2016
46d673a
test: use strictEqual in test-cwd-enoent-repl.js
nitsnwits Dec 1, 2016
c092aa3
test: refactor the code in test-http-keep-alive
edsadr Dec 21, 2016
2968876
test: change assert.strict to assert.strictEqual()
ashita92 Dec 1, 2016
ce95ba6
test: refactor test-stream2-writable
Trott Dec 20, 2016
5afa352
test: refactor test-stdin-script-child
emanuelbuholzer Dec 18, 2016
a123e8c
test: refactoring test-cluster-worker-constructor
crokita Dec 1, 2016
cd08da8
test: change var declarations, add mustCall check
Dec 1, 2016
e205bbd
doc: clarify macosx-firewall suggestion BUILDING
chasestarr Dec 17, 2016
6993d1c
doc: consistent 'Returns:' part two
MylesBorins Dec 21, 2016
0e0dc86
test: refactor test-child-process-stdin
navulirs Dec 23, 2016
f0714d2
test: improve test-cluster-net-listen.js
Dec 1, 2016
f45086b
test: update test-tls-check-server-identity.js
koxauvin Dec 1, 2016
3a9b5b4
test: refactor test-cluster-send-handle-twice.js
amarzavery Dec 1, 2016
9b13d98
test: refactor test-tls-interleave
bchirgwin Dec 1, 2016
f69b01e
test: refactor test-pipe-file-to-http
Dec 1, 2016
f80084c
test: fix and improve debug-break-on-uncaught
thefourtheye Dec 21, 2016
c074982
test: refactor test-child-process-ipc
malenesok007 Dec 1, 2016
6d51108
test: improve code in test-vm-symbols
edsadr Dec 23, 2016
81649fd
test: improve code in test-fs-readfile-error
edsadr Dec 21, 2016
7059543
test: improve the code in test-pipe.js
edsadr Dec 27, 2016
a394d00
doc: var -> const / let in the console.md
vsemozhetbyt Dec 25, 2016
f59b6dd
doc: more efficient example in the console.md
vsemozhetbyt Dec 25, 2016
03d3990
test: refactor the code in test-fs-chmod
edsadr Dec 24, 2016
b5b1ca6
doc: add Working Group dissolution text
williamkapke Nov 17, 2016
e197129
test: refactor test-stdin-from-file
radelmann Dec 19, 2016
e83c121
test: fix flaky test-http-client-timeout-with-data
Trott Dec 23, 2016
cbbe46a
test: s/ASSERT/assert/
cjihrig Dec 30, 2016
a8ff6b9
doc: redirect 'Start a Working Group' to TSC repo
williamkapke Nov 17, 2016
d32d64b
crypto: Use reference count to manage cert_store
AdamMajer Aug 30, 2016
5c8881d
debugger: call `this.resume()` after `this.run()`
lance Dec 2, 2016
8f4c29b
test: stream readableState readingMore state
chmln Dec 1, 2016
2f7270a
test: fail for missing output files
addaleax Dec 6, 2016
2410008
test: refactor test-domain.js
sidthekidder Dec 9, 2016
ffbd630
test: update test-domain-uncaught-exception.js
amazingandyyy Dec 9, 2016
b6c88d6
test: clean up domain-no-error-handler test
weyj4 Dec 15, 2016
906092b
src: fix string format mistake for 32 bit node
posix4e Dec 1, 2016
f26213a
stream, test: test _readableState.emittedReadable
joyeecheung Dec 13, 2016
083ff5c
test: stream readable needReadable state
joyeecheung Dec 12, 2016
cf1587a
test: stream readable resumeScheduled state
Dec 16, 2016
6dfddc8
doc: clarify the review and landing process
joyeecheung Dec 9, 2016
2fb30f8
doc: require() tries first core not native modules
vice Dec 18, 2016
312745a
test: improve test-cluster-worker-constructor.js
edsadr Dec 21, 2016
b3bc996
test: fix flaky test-https-timeout
Trott Dec 22, 2016
2a26a31
test: improve code in test-vm-preserves-property
edsadr Dec 23, 2016
0ea78d4
doc: use "Node.js" in V8 guide
Trott Dec 24, 2016
78d85c6
src: describe what NODE_MODULE_VERSION is for
sam-github Dec 22, 2016
418d5ce
build: add (not) cross-compiled configure flags
piranna Dec 26, 2016
ff5c111
os: fix os.release() for aix and add test
jBarz Dec 13, 2016
4b55e9c
test: add test for SIGWINCH handling by stdio.js
sarahmeyer Dec 1, 2016
4502851
test: refactor test-stream2-unpipe-drain
storytimesolutions Dec 1, 2016
41a67c9
build: add /opt/freeware/... to AIX library path
Dec 13, 2016
2eba1d5
test: use strictEqual in test-http-server
ftatieze Dec 28, 2016
c51c3b0
doc: require two-factor authentication
Trott Dec 30, 2016
cd0ad3f
test: improve test-fs-empty-readStream.js
edsadr Dec 28, 2016
678c563
doc: warn about unvalidated input in child_process
Dec 26, 2016
04fb784
test: improve test-http-allow-req-after-204-res
edsadr Dec 30, 2016
0aa900f
test: avoid assigning this to variables
cjihrig Dec 30, 2016
823bcd6
test: update test-cluster-shared-handle-bind-error
cjihrig Dec 30, 2016
c6cb93f
test: add tests for clearBuffer state machine
captainsafia Dec 1, 2016
0ef4ea6
doc: add joyeecheung to collaborators
joyeecheung Jan 4, 2017
2b6581c
vm: add error message if we abort
fhinkel Sep 17, 2016
69c2ea9
test: add stdin-setrawmode.out file
Dec 6, 2016
a5fdd6a
test: set stdin too for pseudo-tty tests
addaleax Dec 6, 2016
1d7d640
doc: update CONTRIBUTING.MD with link to V8 guide
sarahmeyer Dec 1, 2016
ababc8a
test: use mustCall() for simple flow tracking
cjihrig Jul 15, 2016
f4e76eb
test: refactor test-tls-server-verify
Dec 1, 2016
42a52c0
test: refactor test-net-dns-custom-lookup
funkent Dec 1, 2016
beffa82
test: refactor test-repl-mode.js
cesarhq Dec 1, 2016
7492d3b
test: use common.fixturesDir almost everywhere
bengl May 26, 2016
657d3f3
test: test: refactor test-sync-fileread
jhwohlgemuth Dec 1, 2016
fb9a704
test: refactor test-tls-0-dns-altname
Dec 1, 2016
6625373
tools: add ESLint rule for assert.throws arguments
targos Nov 26, 2016
f0ede65
tools: forbid template literals in assert.throws
targos Dec 16, 2016
87463bf
test: add second argument to assert.throws()
russokj Dec 1, 2016
869b0a6
test: refactoring test-pipe-head
furnox Dec 1, 2016
2c33751
test: invalid package.json causes error when require()ing in directory
Dec 1, 2016
50f7e2f
test: refactor test-preload
Trott Nov 26, 2016
fa8f128
lib,test: use consistent operator linebreak style
targos Dec 8, 2016
84b312c
tools: enforce consistent operator linebreak style
targos Dec 8, 2016
f5c57c7
test: cleanup stream tests
Sep 20, 2016
b342679
crypto: allow adding extra certs to well-known CAs
sam-github Oct 17, 2016
0b2d0eb
fixup! crypto: allow adding extra certs to well-known CAs
sam-github Jan 24, 2017
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: use mustCall() for simple flow tracking
Many of the tests use variables to track when callback functions
are invoked or events are emitted. These variables are then
asserted on process exit. This commit replaces this pattern in
straightforward cases with common.mustCall(). This makes the
tests easier to reason about, leads to a net reduction in lines
of code, and uncovered a few bugs in tests. This commit also
replaces some callbacks that should never be called with
common.fail().

PR-URL: #7753
Reviewed-By: Wyatt Preul <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
cjihrig authored and targos committed Jan 23, 2017
commit ababc8a011e76a7886952b98231858a2762589de
15 changes: 4 additions & 11 deletions test/addons/async-hello-world/test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
'use strict';
var common = require('../../common');
const common = require('../../common');
var assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
var called = false;

process.on('exit', function() {
assert(called);
});

binding(5, function(err, val) {
binding(5, common.mustCall(function(err, val) {
assert.equal(null, err);
assert.equal(10, val);
process.nextTick(function() {
called = true;
});
});
process.nextTick(common.mustCall(function() {}));
}));
8 changes: 2 additions & 6 deletions test/internet/test-http-dns-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* should trigger the error event after each attempt.
*/

require('../common');
const common = require('../common');
var assert = require('assert');
var http = require('http');

var resDespiteError = false;
var hadError = 0;

function httpreq(count) {
Expand All @@ -19,9 +18,7 @@ function httpreq(count) {
port: 80,
path: '/',
method: 'GET'
}, function(res) {
resDespiteError = true;
});
}, common.fail);

req.on('error', function(e) {
console.log(e.message);
Expand All @@ -37,6 +34,5 @@ httpreq(0);


process.on('exit', function() {
assert.equal(false, resDespiteError);
assert.equal(2, hadError);
});
19 changes: 4 additions & 15 deletions test/internet/test-http-https-default-ports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
var common = require('../common');
var assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
Expand All @@ -9,21 +8,11 @@ if (!common.hasCrypto) {
var https = require('https');

var http = require('http');
var gotHttpsResp = false;
var gotHttpResp = false;

process.on('exit', function() {
assert(gotHttpsResp);
assert(gotHttpResp);
console.log('ok');
});

https.get('https://www.google.com/', function(res) {
gotHttpsResp = true;
https.get('https://www.google.com/', common.mustCall(function(res) {
res.resume();
});
}));

http.get('http://www.google.com/', function(res) {
gotHttpResp = true;
http.get('http://www.google.com/', common.mustCall(function(res) {
res.resume();
});
}));
23 changes: 4 additions & 19 deletions test/internet/test-net-connect-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
// https://groups.google.com/forum/#!topic/nodejs/UE0ZbfLt6t8
// https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw

require('../common');
const common = require('../common');
var net = require('net');
var assert = require('assert');

var start = new Date();

var gotTimeout = false;

var gotConnect = false;

var T = 100;

// 192.0.2.1 is part of subnet assigned as "TEST-NET" in RFC 5737.
Expand All @@ -23,22 +19,11 @@ var socket = net.createConnection(9999, '192.0.2.1');

socket.setTimeout(T);

socket.on('timeout', function() {
socket.on('timeout', common.mustCall(function() {
console.error('timeout');
gotTimeout = true;
var now = new Date();
assert.ok(now - start < T + 500);
socket.destroy();
});

socket.on('connect', function() {
console.error('connect');
gotConnect = true;
socket.destroy();
});

}));

process.on('exit', function() {
assert.ok(gotTimeout);
assert.ok(!gotConnect);
});
socket.on('connect', common.fail);
19 changes: 4 additions & 15 deletions test/internet/test-net-connect-unref.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
'use strict';
require('../common');
var assert = require('assert');
const common = require('../common');
var net = require('net');

var client, killed = false, ended = false;
var client;
var TIMEOUT = 10 * 1000;

client = net.createConnection(53, '8.8.8.8', function() {
client.unref();
});

client.on('close', function() {
ended = true;
});

setTimeout(function() {
killed = true;
client.end();
}, TIMEOUT).unref();
client.on('close', common.fail);

process.on('exit', function() {
assert.strictEqual(killed, false, 'A client should have connected');
assert.strictEqual(ended, false, 'A client should stay connected');
});
setTimeout(common.fail, TIMEOUT).unref();
21 changes: 4 additions & 17 deletions test/parallel/test-child-process-buffering.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
var common = require('../common');
var assert = require('assert');

var pwd_called = false;
var childClosed = false;
var childExited = false;

function pwd(callback) {
var output = '';
var child = common.spawnPwd();
Expand All @@ -16,17 +12,14 @@ function pwd(callback) {
output += s;
});

child.on('exit', function(c) {
child.on('exit', common.mustCall(function(c) {
console.log('exit: ' + c);
assert.equal(0, c);
childExited = true;
});
}));

child.on('close', function() {
child.on('close', common.mustCall(function() {
callback(output);
pwd_called = true;
childClosed = true;
});
}));
}


Expand All @@ -35,9 +28,3 @@ pwd(function(result) {
assert.equal(true, result.length > 1);
assert.equal('\n', result[result.length - 1]);
});

process.on('exit', function() {
assert.equal(true, pwd_called);
assert.equal(true, childExited);
assert.equal(true, childClosed);
});
14 changes: 3 additions & 11 deletions test/parallel/test-child-process-disconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,16 @@ if (process.argv[2] === 'child') {
var child = fork(process.argv[1], ['child']);

var childFlag = false;
var childSelfTerminate = false;
var parentEmit = false;
var parentFlag = false;

// when calling .disconnect the event should emit
// and the disconnected flag should be true.
child.on('disconnect', function() {
parentEmit = true;
child.on('disconnect', common.mustCall(function() {
parentFlag = child.connected;
});
}));

// the process should also self terminate without using signals
child.on('exit', function() {
childSelfTerminate = true;
});
child.on('exit', common.mustCall(function() {}));

// when child is listening
child.on('message', function(obj) {
Expand Down Expand Up @@ -91,8 +86,5 @@ if (process.argv[2] === 'child') {
process.on('exit', function() {
assert.equal(childFlag, false);
assert.equal(parentFlag, false);

assert.ok(childSelfTerminate);
assert.ok(parentEmit);
});
}
21 changes: 5 additions & 16 deletions test/parallel/test-child-process-exec-buffer.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
'use strict';
require('../common');
const common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var os = require('os');

var success_count = 0;

var str = 'hello';

// default encoding
exec('echo ' + str, function(err, stdout, stderr) {
exec('echo ' + str, common.mustCall(function(err, stdout, stderr) {
assert.ok('string', typeof stdout, 'Expected stdout to be a string');
assert.ok('string', typeof stderr, 'Expected stderr to be a string');
assert.equal(str + os.EOL, stdout);

success_count++;
});
}));

// no encoding (Buffers expected)
exec('echo ' + str, {
encoding: null
}, function(err, stdout, stderr) {
}, common.mustCall(function(err, stdout, stderr) {
assert.ok(stdout instanceof Buffer, 'Expected stdout to be a Buffer');
assert.ok(stderr instanceof Buffer, 'Expected stderr to be a Buffer');
assert.equal(str + os.EOL, stdout.toString());

success_count++;
});

process.on('exit', function() {
assert.equal(2, success_count);
});
}));
25 changes: 4 additions & 21 deletions test/parallel/test-child-process-exec-cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ const common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;

var success_count = 0;
var error_count = 0;

var pwdcommand, dir;

if (common.isWindows) {
Expand All @@ -16,21 +13,7 @@ if (common.isWindows) {
dir = '/dev';
}

exec(pwdcommand, {cwd: dir}, function(err, stdout, stderr) {
if (err) {
error_count++;
console.log('error!: ' + err.code);
console.log('stdout: ' + JSON.stringify(stdout));
console.log('stderr: ' + JSON.stringify(stderr));
assert.equal(false, err.killed);
} else {
success_count++;
console.log(stdout);
assert.ok(stdout.indexOf(dir) == 0);
}
});

process.on('exit', function() {
assert.equal(1, success_count);
assert.equal(0, error_count);
});
exec(pwdcommand, {cwd: dir}, common.mustCall(function(err, stdout, stderr) {
assert.ifError(err);
assert.ok(stdout.indexOf(dir) == 0);
}));
11 changes: 2 additions & 9 deletions test/parallel/test-child-process-exec-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ var assert = require('assert');
var child_process = require('child_process');

function test(fun, code) {
var errors = 0;

fun('does-not-exist', function(err) {
fun('does-not-exist', common.mustCall(function(err) {
assert.equal(err.code, code);
assert(/does\-not\-exist/.test(err.cmd));
errors++;
});

process.on('exit', function() {
assert.equal(errors, 1);
});
}));
}

if (common.isWindows) {
Expand Down
19 changes: 4 additions & 15 deletions test/parallel/test-child-process-exit-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,18 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var path = require('path');

var exits = 0;

var exitScript = path.join(common.fixturesDir, 'exit.js');
var exitChild = spawn(process.argv[0], [exitScript, 23]);
exitChild.on('exit', function(code, signal) {
exitChild.on('exit', common.mustCall(function(code, signal) {
assert.strictEqual(code, 23);
assert.strictEqual(signal, null);

exits++;
});
}));


var errorScript = path.join(common.fixturesDir,
'child_process_should_emit_error.js');
var errorChild = spawn(process.argv[0], [errorScript]);
errorChild.on('exit', function(code, signal) {
errorChild.on('exit', common.mustCall(function(code, signal) {
assert.ok(code !== 0);
assert.strictEqual(signal, null);

exits++;
});


process.on('exit', function() {
assert.equal(2, exits);
});
}));
Loading