Browse Source

test: enable linting for tests

Enable linting for the test directory. A number of changes was made so
all tests conform the current rules used by lib and src directories. The
only exception for tests is that unreachable (dead) code is allowed.

test-fs-non-number-arguments-throw had to be excluded from the changes
because of a weird issue on Windows CI.

PR-URL: https://github.com/nodejs/io.js/pull/1721
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v2.3.1-release
Roman Reiss 10 years ago
parent
commit
f29762f4dd
  1. 3
      .eslintignore
  2. 5
      .eslintrc
  3. 2
      Makefile
  4. 5
      test/.eslintrc
  5. 7
      test/addons/async-hello-world/test.js
  6. 1
      test/addons/at-exit/test.js
  7. 1
      test/addons/hello-world-function-export/test.js
  8. 1
      test/addons/hello-world/test.js
  9. 1
      test/addons/repl-domain-abort/test.js
  10. 1
      test/addons/smalloc-alloc/test.js
  11. 23
      test/common.js
  12. 3
      test/debugger/helper-debugger-repl.js
  13. 3
      test/debugger/test-debug-break-on-uncaught.js
  14. 7
      test/debugger/test-debugger-client.js
  15. 1
      test/debugger/test-debugger-debug-brk.js
  16. 1
      test/debugger/test-debugger-remote.js
  17. 1
      test/debugger/test-debugger-repl-break-in-module.js
  18. 3
      test/debugger/test-debugger-repl-restart.js
  19. 1
      test/debugger/test-debugger-repl-term.js
  20. 1
      test/debugger/test-debugger-repl-utf8.js
  21. 1
      test/debugger/test-debugger-repl.js
  22. 1
      test/disabled/GH-670.js
  23. 1
      test/disabled/test-cat.js
  24. 1
      test/disabled/test-child-process-custom-fds.js
  25. 1
      test/disabled/test-child-process-customfd-bounded.js
  26. 1
      test/disabled/test-child-process-uid-gid.js
  27. 1
      test/disabled/test-debug-brk-file.js
  28. 1
      test/disabled/test-debug-brk-no-arg.js
  29. 1
      test/disabled/test-dgram-multicast.js
  30. 1
      test/disabled/test-dgram-send-error.js
  31. 1
      test/disabled/test-dgram-unix-anon.js
  32. 1
      test/disabled/test-dgram-unix.js
  33. 3
      test/disabled/test-eio-race.js
  34. 1
      test/disabled/test-eio-race2.js
  35. 1
      test/disabled/test-eio-race3.js
  36. 1
      test/disabled/test-eio-race4.js
  37. 1
      test/disabled/test-fs-largefile.js
  38. 1
      test/disabled/test-http-abort-stream-end.js
  39. 1
      test/disabled/test-http-agent2.js
  40. 1
      test/disabled/test-http-big-proxy-responses.js
  41. 1
      test/disabled/test-http-head-request.js
  42. 1
      test/disabled/test-http-stress.js
  43. 1
      test/disabled/test-http-tls.js
  44. 39
      test/disabled/test-https-loop-to-google.js
  45. 1
      test/disabled/test-idle-watcher.js
  46. 1
      test/disabled/test-net-fd-passing.js
  47. 1
      test/disabled/test-net-tls-pummel.js
  48. 1
      test/disabled/test-net-tls.js
  49. 1
      test/disabled/test-process-title.js
  50. 18
      test/disabled/test-readline.js
  51. 1
      test/disabled/test-remote-module-loading.js
  52. 1
      test/disabled/test-sendfd.js
  53. 1
      test/disabled/test-setuidgid.js
  54. 4
      test/disabled/test-tls-large-push.js
  55. 1
      test/disabled/test-tls-server.js
  56. 1
      test/disabled/test-tty-stdio.js
  57. 1
      test/disabled/tls-client.js
  58. 1
      test/disabled/tls_client.js
  59. 1
      test/disabled/tls_server.js
  60. 2
      test/fixtures/child-process-persistent.js
  61. 3
      test/gc/node_modules/weak/lib/weak.js
  62. 11
      test/gc/test-http-client-connaborted.js
  63. 11
      test/gc/test-http-client-onerror.js
  64. 19
      test/gc/test-http-client-timeout.js
  65. 15
      test/gc/test-http-client.js
  66. 9
      test/gc/test-net-timeout.js
  67. 5
      test/internet/test-dgram-broadcast-multi-process.js
  68. 5
      test/internet/test-dgram-multicast-multi-process.js
  69. 1
      test/internet/test-dns-txt-sigsegv.js
  70. 7
      test/internet/test-dns.js
  71. 1
      test/internet/test-http-dns-fail.js
  72. 1
      test/internet/test-http-https-default-ports.js
  73. 1
      test/internet/test-net-connect-timeout.js
  74. 3
      test/internet/test-net-connect-unref.js
  75. 1
      test/internet/test-tls-connnect-melissadata.js
  76. 1
      test/internet/test-tls-reuse-host-from-socket.js
  77. 1
      test/message/2100bytes.js
  78. 1
      test/message/error_exit.js
  79. 1
      test/message/eval_messages.js
  80. 1
      test/message/hello_world.js
  81. 1
      test/message/max_tick_depth.js
  82. 1
      test/message/nexttick_throw.js
  83. 1
      test/message/stack_overflow.js
  84. 1
      test/message/stdin_messages.js
  85. 1
      test/message/throw_custom_error.js
  86. 2
      test/message/throw_custom_error.out
  87. 4
      test/message/throw_in_line_with_tabs.js
  88. 2
      test/message/throw_in_line_with_tabs.out
  89. 1
      test/message/throw_non_error.js
  90. 2
      test/message/throw_non_error.out
  91. 1
      test/message/throw_null.js
  92. 2
      test/message/throw_null.out
  93. 1
      test/message/throw_undefined.js
  94. 2
      test/message/throw_undefined.out
  95. 1
      test/message/timeout_throw.js
  96. 1
      test/message/undefined_reference_in_new_context.js
  97. 1
      test/message/vm_display_runtime_error.js
  98. 1
      test/message/vm_display_syntax_error.js
  99. 13
      test/message/vm_dont_display_runtime_error.js
  100. 13
      test/message/vm_dont_display_syntax_error.js

3
.eslintignore

@ -1 +1,4 @@
lib/punycode.js
test/fixtures
test/**/node_modules
test/parallel/test-fs-non-number-arguments-throw.js

5
.eslintrc

@ -8,6 +8,7 @@ ecmaFeatures:
octalLiterals: true
binaryLiterals: true
generators: true
forOf: true
rules:
# Possible Errors
@ -54,6 +55,10 @@ rules:
space-infix-ops: 2
## require spaces return, throw, case
space-return-throw-case: 2
## no space before function, eg. 'function()'
space-before-function-paren: [2, "never"]
## require space before blocks, eg 'function() {'
space-before-blocks: [2, "always"]
## require parens for Constructor
new-parens: 2
## max 80 length

2
Makefile

@ -375,7 +375,7 @@ bench-idle:
./$(NODE_EXE) benchmark/idle_clients.js &
jslint:
./$(NODE_EXE) tools/eslint/bin/eslint.js src lib --reset --quiet
./$(NODE_EXE) tools/eslint/bin/eslint.js src lib test --reset --quiet
CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_lttng.cc

5
test/.eslintrc

@ -0,0 +1,5 @@
## Test-specific linter rules
rules:
## allow unreachable code
no-unreachable: 0

7
test/addons/async-hello-world/test.js

@ -1,15 +1,16 @@
'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
var called = false;
process.on('exit', function () {
process.on('exit', function() {
assert(called);
});
binding(5, function (err, val) {
binding(5, function(err, val) {
assert.equal(null, err);
assert.equal(10, val);
process.nextTick(function () {
process.nextTick(function() {
called = true;
});
});

1
test/addons/at-exit/test.js

@ -1 +1,2 @@
'use strict';
var binding = require('./build/Release/binding');

1
test/addons/hello-world-function-export/test.js

@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
assert.equal('world', binding());

1
test/addons/hello-world/test.js

@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
assert.equal('world', binding.hello());

1
test/addons/repl-domain-abort/test.js

@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var repl = require('repl');
var stream = require('stream');

1
test/addons/smalloc-alloc/test.js

@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
var obj = binding.alloc(16);

23
test/common.js

@ -1,3 +1,4 @@
'use strict';
var path = require('path');
var fs = require('fs');
var assert = require('assert');
@ -107,8 +108,8 @@ if (process.env.NODE_COMMON_PIPE) {
if (process.platform === 'win32') {
exports.faketimeCli = false;
} else {
exports.faketimeCli = path.join(__dirname, "..", "tools", "faketime", "src",
"faketime");
exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src',
'faketime');
}
var ifaces = os.networkInterfaces();
@ -307,7 +308,7 @@ exports.mustCall = function(fn, expected) {
var context = {
expected: expected,
actual: 0,
stack: (new Error).stack,
stack: (new Error()).stack,
name: fn.name || '<anonymous>'
};
@ -345,11 +346,11 @@ if (process.platform === 'win32') {
*/
exports.getServiceName = function getServiceName(port, protocol) {
if (port == null) {
throw new Error("Missing port number");
throw new Error('Missing port number');
}
if (typeof protocol !== 'string') {
throw new Error("Protocol must be a string");
throw new Error('Protocol must be a string');
}
/*
@ -360,10 +361,10 @@ exports.getServiceName = function getServiceName(port, protocol) {
try {
/*
* I'm not a big fan of readFileSync, but reading /etc/services asynchronously
* here would require implementing a simple line parser, which seems overkill
* for a simple utility function that is not running concurrently with any
* other one.
* I'm not a big fan of readFileSync, but reading /etc/services
* asynchronously here would require implementing a simple line parser,
* which seems overkill for a simple utility function that is not running
* concurrently with any other one.
*/
var servicesContent = fs.readFileSync(etcServicesFileName,
{ encoding: 'utf8'});
@ -380,7 +381,7 @@ exports.getServiceName = function getServiceName(port, protocol) {
}
return serviceName;
}
};
exports.hasMultiLocalhost = function hasMultiLocalhost() {
var TCP = process.binding('tcp_wrap').TCP;
@ -397,7 +398,7 @@ exports.isValidHostname = function(str) {
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');
return !!str.match(re) && str.length <= 255;
}
};
exports.fileExists = function(pathname) {
try {

3
test/debugger/helper-debugger-repl.js

@ -1,3 +1,4 @@
'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
var assert = require('assert');
@ -55,7 +56,7 @@ function startDebugger(scriptToDebug) {
quitCalled = true;
child.stdin.write('quit');
child.kill('SIGTERM');
}
};
setTimeout(function() {
console.error('dying badly buffer=%j', buffer);

3
test/debugger/test-debug-break-on-uncaught.js

@ -1,3 +1,4 @@
'use strict';
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
@ -44,7 +45,7 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) {
child.on('close', function() {
assert(asserted, 'debugger did not pause on exception');
if (next) next();
})
});
var exceptions = [];

7
test/debugger/test-debugger-client.js

@ -1,3 +1,4 @@
'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
var assert = require('assert');
@ -66,7 +67,7 @@ var d = 'Content-Length: 466\r\n\r\n' +
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
'"sourceStart":"(function (module, exports, require) {' +
'"sourceStart":"(function(module, exports, require) {' +
'var dns = process.binding(\'cares\')' +
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
@ -127,8 +128,8 @@ addTest(function(client, done) {
var connectCount = 0;
var script = 'setTimeout(function () { console.log("blah"); });' +
'setInterval(function () {}, 1000000);';
var script = 'setTimeout(function() { console.log("blah"); });' +
'setInterval(function() {}, 1000000);';
var nodeProcess;

1
test/debugger/test-debugger-debug-brk.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

1
test/debugger/test-debugger-remote.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

1
test/debugger/test-debugger-repl-break-in-module.js

@ -1,3 +1,4 @@
'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('break-in-module/main.js');

3
test/debugger/test-debugger-repl-restart.js

@ -1,3 +1,4 @@
'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
@ -7,7 +8,7 @@ var linesWithBreakpoint = [
// We slice here, because addTest will change the given array.
repl.addTest('sb(6)', linesWithBreakpoint.slice());
var initialLines = repl.initialLines.slice()
var initialLines = repl.initialLines.slice();
initialLines.splice(2, 0, /Restoring/, /Warning/);
// Restart the debugged script

1
test/debugger/test-debugger-repl-term.js

@ -1,3 +1,4 @@
'use strict';
process.env.NODE_FORCE_READLINE = 1;
var repl = require('./helper-debugger-repl.js');

1
test/debugger/test-debugger-repl-utf8.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var script = common.fixturesDir + '/breakpoints_utf8.js';
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;

1
test/debugger/test-debugger-repl.js

@ -1,3 +1,4 @@
'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');

1
test/disabled/GH-670.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var https = require('https');

1
test/disabled/test-cat.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var assert = require('assert');
var http = require('http');

1
test/disabled/test-child-process-custom-fds.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-child-process-customfd-bounded.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var bigish = Array(200);

1
test/disabled/test-child-process-uid-gid.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

1
test/disabled/test-debug-brk-file.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

1
test/disabled/test-debug-brk-no-arg.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

1
test/disabled/test-dgram-multicast.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-dgram-send-error.js

@ -1,3 +1,4 @@
'use strict';
// Some operating systems report errors when an UDP message is sent to an
// unreachable host. This error can be reported by sendto() and even by
// recvfrom(). Node should not propagate this error to the user.

1
test/disabled/test-dgram-unix-anon.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-dgram-unix.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

3
test/disabled/test-eio-race.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
@ -36,7 +37,7 @@ function tryToKillEventLoop() {
// Generate a lot of thread pool events
var pos = 0;
fs.open(filename, 'r', 0666, function(err, fd) {
fs.open(filename, 'r', 0o666, function(err, fd) {
if (err) throw err;
function readChunk() {

1
test/disabled/test-eio-race2.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');

1
test/disabled/test-eio-race3.js

@ -1,3 +1,4 @@
'use strict';
/* XXX Can this test be modified to not call the now-removed wait()? */
var common = require('../common');

1
test/disabled/test-eio-race4.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');

1
test/disabled/test-fs-largefile.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path'),

1
test/disabled/test-http-abort-stream-end.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-http-agent2.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');

1
test/disabled/test-http-big-proxy-responses.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util'),

1
test/disabled/test-http-head-request.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-http-stress.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-http-tls.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

39
test/disabled/test-https-loop-to-google.js

@ -1,3 +1,4 @@
'use strict';
// Failing test for https
// Will fail with "socket hang up" for 4 out of 10 requests
@ -7,26 +8,20 @@
var common = require('../common');
var https = require('https');
for (var i = 0; i < 10; ++i)
{
https.get(
{
host: 'www.google.com',
path: '/accounts/o8/id',
port: 443
}, function(res)
{
var data = '';
res.on('data', function(chunk)
{
data += chunk;
});
res.on('end', function()
{
console.log(res.statusCode);
});
}).on('error', function(error)
{
console.log(error);
});
for (var i = 0; i < 10; ++i) {
https.get({
host: 'www.google.com',
path: '/accounts/o8/id',
port: 443
}, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
console.log(res.statusCode);
});
}).on('error', function(error) {
console.log(error);
});
}

1
test/disabled/test-idle-watcher.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-net-fd-passing.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');

1
test/disabled/test-net-tls-pummel.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-net-tls.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');

1
test/disabled/test-process-title.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

18
test/disabled/test-readline.js

@ -1,3 +1,4 @@
'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
// Yet another use-case for require('tty').spawn ?
var common = require('../common');
@ -36,10 +37,10 @@ var readlineFakeStream = function() {
}
});
var _stdoutWrite = process.stdout.write;
process.stdout.write = function (data) {
process.stdout.write = function(data) {
data.split('').forEach(rl.written_bytes.push.bind(rl.written_bytes));
_stdoutWrite.apply(this, arguments);
}
};
rl.written_bytes = written_bytes;
return rl;
};
@ -49,7 +50,7 @@ var written_bytes_length, refreshed;
rl.write('foo');
assert.equal(3, rl.cursor);
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function (key) {
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
rl.write.apply(rl, key.home);
assert.equal(0, rl.cursor);
rl.write.apply(rl, key.end);
@ -72,7 +73,7 @@ rl.write.apply(rl, key.xterm.home);
{cursor: 7, key: key.xterm.metab},
{cursor: 4, key: key.xterm.metab},
{cursor: 0, key: key.xterm.metab},
].forEach(function (action) {
].forEach(function(action) {
written_bytes_length = rl.written_bytes.length;
rl.write.apply(rl, action.key);
assert.equal(action.cursor, rl.cursor);
@ -83,7 +84,14 @@ rl.write.apply(rl, key.xterm.home);
rl = readlineFakeStream();
rl.write('foo bar.hop/zoo');
rl.write.apply(rl, key.xterm.home);
['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''].forEach(function (expectedLine) {
[
'bar.hop/zoo',
'.hop/zoo',
'hop/zoo',
'/zoo',
'zoo',
''
].forEach(function(expectedLine) {
rl.write.apply(rl, key.xterm.metad);
assert.equal(0, rl.cursor);
assert.equal(expectedLine, rl.line);

1
test/disabled/test-remote-module-loading.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/test-sendfd.js

@ -1,3 +1,4 @@
'use strict';
// Test sending and receiving a file descriptor.
//
// This test is pretty complex. It ends up spawning test/fixtures/recvfd.js

1
test/disabled/test-setuidgid.js

@ -1,3 +1,4 @@
'use strict';
// Requires special privileges
var common = require('../common');
var assert = require('assert');

4
test/disabled/test-tls-large-push.js

@ -1,3 +1,5 @@
/* eslint-disable no-debugger */
'use strict';
// Server sends a large string. Client counts bytes and pauses every few
// seconds. Makes sure that pause and resume work properly.
var common = require('../common');
@ -39,7 +41,7 @@ server.listen(common.PORT, function() {
/*
client.pause();
process.nextTick(function () {
process.nextTick(function() {
client.resume();
});
*/

1
test/disabled/test-tls-server.js

@ -1,3 +1,4 @@
'use strict';
// Example of new TLS API. Test with:
//
// $> openssl s_client -connect localhost:12346 \

1
test/disabled/test-tty-stdio.js

@ -1,3 +1,4 @@
'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
var common = require('../common');
var assert = require('assert');

1
test/disabled/tls-client.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var tls = require('tls');
var fs = require('fs');

1
test/disabled/tls_client.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/disabled/tls_server.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

2
test/fixtures/child-process-persistent.js

@ -1 +1 @@
setInterval(function () {}, 500);
setInterval(function() {}, 500);

3
test/gc/node_modules/weak/lib/weak.js

@ -1,3 +1,4 @@
'use strict';
var bindings
try {
bindings = require('../build/Release/weakref.node')
@ -13,6 +14,6 @@ module.exports = bindings.create
// backwards-compat with node-weakref
bindings.weaken = bindings.create
Object.keys(bindings).forEach(function (name) {
Object.keys(bindings).forEach(function(name) {
module.exports[name] = bindings[name]
})

11
test/gc/test-http-client-connaborted.js

@ -1,3 +1,4 @@
'use strict';
// just like test/gc/http-client.js,
// but aborting every connection that comes in.
@ -15,7 +16,7 @@ var http = require('http'),
assert = require('assert'),
PORT = common.PORT;
console.log('We should do '+ todo +' requests');
console.log('We should do ' + todo + ' requests');
var http = require('http');
var server = http.createServer(serverHandler);
@ -25,9 +26,9 @@ function getall() {
if (count >= todo)
return;
(function(){
(function() {
function cb(res) {
done+=1;
done += 1;
statusLater();
}
@ -39,7 +40,7 @@ function getall() {
count++;
weak(req, afterGC);
})()
})();
setImmediate(getall);
}
@ -47,7 +48,7 @@ function getall() {
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
function afterGC() {
countGC ++;
}

11
test/gc/test-http-client-onerror.js

@ -1,3 +1,4 @@
'use strict';
// just like test/gc/http-client.js,
// but with an on('error') handler that does nothing.
@ -17,7 +18,7 @@ var http = require('http'),
assert = require('assert'),
PORT = common.PORT;
console.log('We should do '+ todo +' requests');
console.log('We should do ' + todo + ' requests');
var http = require('http');
var server = http.createServer(serverHandler);
@ -27,10 +28,10 @@ function getall() {
if (count >= todo)
return;
(function(){
(function() {
function cb(res) {
res.resume();
done+=1;
done += 1;
statusLater();
}
function onerror(er) {
@ -45,7 +46,7 @@ function getall() {
count++;
weak(req, afterGC);
})()
})();
setImmediate(getall);
}
@ -53,7 +54,7 @@ function getall() {
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
function afterGC() {
countGC ++;
}

19
test/gc/test-http-client-timeout.js

@ -1,10 +1,11 @@
'use strict';
// just like test/gc/http-client.js,
// but with a timeout set
function serverHandler(req, res) {
setTimeout(function () {
setTimeout(function() {
req.resume();
res.writeHead(200)
res.writeHead(200);
res.end('hello\n');
}, 100);
}
@ -19,7 +20,7 @@ var http = require('http'),
assert = require('assert'),
PORT = common.PORT;
console.log('We should do '+ todo +' requests');
console.log('We should do ' + todo + ' requests');
var http = require('http');
var server = http.createServer(serverHandler);
@ -29,10 +30,10 @@ function getall() {
if (count >= todo)
return;
(function(){
(function() {
function cb(res) {
res.resume();
done+=1;
done += 1;
statusLater();
}
@ -42,13 +43,13 @@ function getall() {
port: PORT
}, cb);
req.on('error', cb);
req.setTimeout(10, function(){
console.log('timeout (expected)')
req.setTimeout(10, function() {
console.log('timeout (expected)');
});
count++;
weak(req, afterGC);
})()
})();
setImmediate(getall);
}
@ -56,7 +57,7 @@ function getall() {
for(var i = 0; i < 10; i++)
getall();
function afterGC(){
function afterGC() {
countGC ++;
}

15
test/gc/test-http-client.js

@ -1,3 +1,4 @@
'use strict';
// just a simple http server and client.
function serverHandler(req, res) {
@ -15,7 +16,7 @@ var http = require('http'),
assert = require('assert'),
PORT = common.PORT;
console.log('We should do '+ todo +' requests');
console.log('We should do ' + todo + ' requests');
var http = require('http');
var server = http.createServer(serverHandler);
@ -26,11 +27,11 @@ function getall() {
if (count >= todo)
return;
(function(){
(function() {
function cb(res) {
res.resume();
console.error('in cb')
done+=1;
console.error('in cb');
done += 1;
res.on('end', gc);
}
@ -38,11 +39,11 @@ function getall() {
hostname: 'localhost',
pathname: '/',
port: PORT
}, cb)
}, cb);
count++;
weak(req, afterGC);
})()
})();
setImmediate(getall);
}
@ -50,7 +51,7 @@ function getall() {
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
function afterGC() {
countGC ++;
}

9
test/gc/test-net-timeout.js

@ -1,3 +1,4 @@
'use strict';
// just like test/gc/http-client-timeout.js,
// but using a net server/client instead
@ -11,7 +12,7 @@ function serverHandler(sock) {
sock.on('error', function(err) {
assert.strictEqual(err.code, 'ECONNRESET');
});
timer = setTimeout(function () {
timer = setTimeout(function() {
sock.end('hello\n');
}, 100);
}
@ -26,7 +27,7 @@ var net = require('net'),
assert = require('assert'),
PORT = common.PORT;
console.log('We should do '+ todo +' requests');
console.log('We should do ' + todo + ' requests');
var server = net.createServer(serverHandler);
server.listen(PORT, getall);
@ -35,7 +36,7 @@ function getall() {
if (count >= todo)
return;
(function(){
(function() {
var req = net.connect(PORT, '127.0.0.1');
req.resume();
req.setTimeout(10, function() {
@ -55,7 +56,7 @@ function getall() {
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
function afterGC() {
countGC ++;
}

5
test/internet/test-dgram-broadcast-multi-process.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
@ -144,7 +145,7 @@ if (process.argv[2] !== 'child') {
// bind the address explicitly for sending
// INADDR_BROADCAST to only one interface
sendSocket.bind(common.PORT, bindAddress);
sendSocket.on('listening', function () {
sendSocket.on('listening', function() {
sendSocket.setBroadcast(true);
});
@ -162,9 +163,7 @@ if (process.argv[2] !== 'child') {
sendSocket.send(buf, 0, buf.length,
common.PORT, LOCAL_BROADCAST_HOST, function(err) {
if (err) throw err;
console.error('[PARENT] sent %s to %s:%s',
util.inspect(buf.toString()),
LOCAL_BROADCAST_HOST, common.PORT);

5
test/internet/test-dgram-multicast-multi-process.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
@ -129,7 +130,7 @@ if (process.argv[2] !== 'child') {
sendSocket.bind();
// The socket is actually created async now
sendSocket.on('listening', function () {
sendSocket.on('listening', function() {
sendSocket.setTTL(1);
sendSocket.setBroadcast(true);
sendSocket.setMulticastTTL(1);
@ -206,7 +207,7 @@ if (process.argv[2] === 'child') {
listenSocket.bind(common.PORT);
listenSocket.on('listening', function () {
listenSocket.on('listening', function() {
listenSocket.addMembership(LOCAL_BROADCAST_HOST);
});
}

1
test/internet/test-dns-txt-sigsegv.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var dns = require('dns');

7
test/internet/test-dns.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert'),
dns = require('dns'),
@ -500,7 +501,8 @@ TEST(function test_lookup_null_all(done) {
TEST(function test_lookup_all_ipv4(done) {
var req = dns.lookup('www.google.com', {all: true, family: 4}, function(err, ips) {
var req = dns.lookup('www.google.com', {all: true, family: 4},
function(err, ips) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
@ -518,7 +520,8 @@ TEST(function test_lookup_all_ipv4(done) {
TEST(function test_lookup_all_ipv6(done) {
var req = dns.lookup('www.google.com', {all: true, family: 6}, function(err, ips) {
var req = dns.lookup('www.google.com', {all: true, family: 6},
function(err, ips) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);

1
test/internet/test-http-dns-fail.js

@ -1,3 +1,4 @@
'use strict';
/*
* Repeated requests for a domain that fails to resolve
* should trigger the error event after each attempt.

1
test/internet/test-http-https-default-ports.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/internet/test-net-connect-timeout.js

@ -1,3 +1,4 @@
'use strict';
// This example attempts to time out before the connection is established
// https://groups.google.com/forum/#!topic/nodejs/UE0ZbfLt6t8
// https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw

3
test/internet/test-net-connect-unref.js

@ -1,9 +1,10 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
var client, killed = false, ended = false;
var TIMEOUT = 10 * 1000
var TIMEOUT = 10 * 1000;
client = net.createConnection(53, '8.8.8.8', function() {
client.unref();

1
test/internet/test-tls-connnect-melissadata.js

@ -1,3 +1,4 @@
'use strict';
// Test for authorized access to the server which has a cross root
// certification between Starfield Class 2 and ValiCert Class 2
var tls = require('tls');

1
test/internet/test-tls-reuse-host-from-socket.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/2100bytes.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');

1
test/message/error_exit.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/eval_messages.js

@ -1,3 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');

1
test/message/hello_world.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/max_tick_depth.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
process.maxTickDepth = 10;

1
test/message/nexttick_throw.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/stack_overflow.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/stdin_messages.js

@ -1,3 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');

1
test/message/throw_custom_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

2
test/message/throw_custom_error.out

@ -1,5 +1,5 @@
before
*test*message*throw_custom_error.js:7
*test*message*throw_custom_error.js:8
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^
MyCustomError: This is a custom message

4
test/message/throw_in_line_with_tabs.js

@ -1,9 +1,11 @@
/* eslint-disable indent */
'use strict';
var common = require('../common');
var assert = require('assert');
console.error('before');
(function () {
(function() {
// these lines should contain tab!
throw ({ foo: 'bar' });
})();

2
test/message/throw_in_line_with_tabs.out

@ -1,5 +1,5 @@
before
*test*message*throw_in_line_with_tabs.js:8
*test*message*throw_in_line_with_tabs.js:10
throw ({ foo: 'bar' });
^
[object Object]

1
test/message/throw_non_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

2
test/message/throw_non_error.out

@ -1,5 +1,5 @@
before
*test*message*throw_non_error.js:7
*test*message*throw_non_error.js:8
throw ({ foo: 'bar' });
^
[object Object]

1
test/message/throw_null.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

2
test/message/throw_null.out

@ -1,5 +1,5 @@
*test*message*throw_null.js:4
*test*message*throw_null.js:5
throw null;
^
null

1
test/message/throw_undefined.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

2
test/message/throw_undefined.out

@ -1,5 +1,5 @@
*test*message*throw_undefined.js:4
*test*message*throw_undefined.js:5
throw undefined;
^
undefined

1
test/message/timeout_throw.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');

1
test/message/undefined_reference_in_new_context.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');

1
test/message/vm_display_runtime_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');

1
test/message/vm_display_syntax_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');

13
test/message/vm_dont_display_runtime_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
@ -5,17 +6,17 @@ var vm = require('vm');
console.error('beginning');
try {
vm.runInThisContext('throw new Error("boo!")', {
filename: 'test.vm',
displayErrors: false
});
vm.runInThisContext('throw new Error("boo!")', {
filename: 'test.vm',
displayErrors: false
});
} catch (e) {}
console.error('middle');
vm.runInThisContext('throw new Error("boo!")', {
filename: 'test.vm',
displayErrors: false
filename: 'test.vm',
displayErrors: false
});
console.error('end');

13
test/message/vm_dont_display_syntax_error.js

@ -1,3 +1,4 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
@ -5,17 +6,17 @@ var vm = require('vm');
console.error('beginning');
try {
vm.runInThisContext('var 5;', {
filename: 'test.vm',
displayErrors: false
});
vm.runInThisContext('var 5;', {
filename: 'test.vm',
displayErrors: false
});
} catch (e) {}
console.error('middle');
vm.runInThisContext('var 5;', {
filename: 'test.vm',
displayErrors: false
filename: 'test.vm',
displayErrors: false
});
console.error('end');

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save