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

tools,test: enable multiline-comment-style rule in tests #35485

Merged
merged 2 commits into from
Oct 7, 2020
Merged
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
3 changes: 1 addition & 2 deletions test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ env:
es6: true

rules:
# ECMAScript 6
# http://eslint.org/docs/rules/#ecmascript-6
no-var: error
prefer-const: error
symbol-description: off
multiline-comment-style: ["error", "separate-lines"]

no-restricted-syntax:
# Config copied from .eslintrc.js
Expand Down
161 changes: 80 additions & 81 deletions test/async-hooks/test-enable-disable.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,84 @@
/*
* Test Steps Explained
* ====================
*
* Initializing hooks:
*
* We initialize 3 hooks. For hook2 and hook3 we register a callback for the
* "before" and in case of hook3 also for the "after" invocations.
*
* Enabling hooks initially:
*
* We only enable hook1 and hook3 initially.
*
* Enabling hook2:
*
* When hook3's "before" invocation occurs we enable hook2. Since this
* happens right before calling `onfirstImmediate` hook2 will miss all hook
* invocations until then, including the "init" and "before" of the first
* Immediate.
* However afterwards it collects all invocations that follow on the first
* Immediate as well as all invocations on the second Immediate.
*
* This shows that a hook can enable another hook inside a life time event
* callback.
*
*
* Disabling hook1
*
* Since we registered the "before" callback for hook2 it will execute it
* right before `onsecondImmediate` is called.
* At that point we disable hook1 which is why it will miss all invocations
* afterwards and thus won't include the second "after" as well as the
* "destroy" invocations
*
* This shows that a hook can disable another hook inside a life time event
* callback.
*
* Disabling hook3
*
* When the second "after" invocation occurs (after onsecondImmediate), hook3
* disables itself.
* As a result it will not receive the "destroy" invocation.
*
* This shows that a hook can disable itself inside a life time event callback.
*
* Sample Test Log
* ===============
*
* - setting up first Immediate
* hook1.init.uid-5
* hook3.init.uid-5
* - finished setting first Immediate

* hook1.before.uid-5
* hook3.before.uid-5
* - enabled hook2
* - entering onfirstImmediate

* - setting up second Immediate
* hook1.init.uid-6
* hook3.init.uid-6
* hook2.init.uid-6
* - finished setting second Immediate
// Test Steps Explained
// ====================
//
// Initializing hooks:
//
// We initialize 3 hooks. For hook2 and hook3 we register a callback for the
// "before" and in case of hook3 also for the "after" invocations.
//
// Enabling hooks initially:
//
// We only enable hook1 and hook3 initially.
//
// Enabling hook2:
//
// When hook3's "before" invocation occurs we enable hook2. Since this
// happens right before calling `onfirstImmediate` hook2 will miss all hook
// invocations until then, including the "init" and "before" of the first
// Immediate.
// However afterwards it collects all invocations that follow on the first
// Immediate as well as all invocations on the second Immediate.
//
// This shows that a hook can enable another hook inside a life time event
// callback.
//
//
// Disabling hook1
//
// Since we registered the "before" callback for hook2 it will execute it
// right before `onsecondImmediate` is called.
// At that point we disable hook1 which is why it will miss all invocations
// afterwards and thus won't include the second "after" as well as the
// "destroy" invocations
//
// This shows that a hook can disable another hook inside a life time event
// callback.
//
// Disabling hook3
//
// When the second "after" invocation occurs (after onsecondImmediate), hook3
// disables itself.
// As a result it will not receive the "destroy" invocation.
//
// This shows that a hook can disable itself inside a life time event callback.
//
// Sample Test Log
// ===============
//
// - setting up first Immediate
// hook1.init.uid-5
// hook3.init.uid-5
// - finished setting first Immediate
//
// hook1.before.uid-5
// hook3.before.uid-5
// - enabled hook2
// - entering onfirstImmediate
//
// - setting up second Immediate
// hook1.init.uid-6
// hook3.init.uid-6
// hook2.init.uid-6
// - finished setting second Immediate
//
// - exiting onfirstImmediate
// hook1.after.uid-5
// hook3.after.uid-5
// hook2.after.uid-5
// hook1.destroy.uid-5
// hook3.destroy.uid-5
// hook2.destroy.uid-5
// hook1.before.uid-6
// hook3.before.uid-6
// hook2.before.uid-6
// - disabled hook1
// - entering onsecondImmediate
// - exiting onsecondImmediate
// hook3.after.uid-6
// - disabled hook3
// hook2.after.uid-6
// hook2.destroy.uid-6

* - exiting onfirstImmediate
* hook1.after.uid-5
* hook3.after.uid-5
* hook2.after.uid-5
* hook1.destroy.uid-5
* hook3.destroy.uid-5
* hook2.destroy.uid-5
* hook1.before.uid-6
* hook3.before.uid-6
* hook2.before.uid-6
* - disabled hook1
* - entering onsecondImmediate
* - exiting onsecondImmediate
* hook3.after.uid-6
* - disabled hook3
* hook2.after.uid-6
* hook2.destroy.uid-6
*/

'use strict';

Expand Down
8 changes: 3 additions & 5 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,9 @@ const PIPE = (() => {
return path.join(pipePrefix, pipeName);
})();

/*
* Check that when running a test with
* `$node --abort-on-uncaught-exception $file child`
* the process aborts.
*/
// Check that when running a test with
// `$node --abort-on-uncaught-exception $file child`
// the process aborts.
function childShouldThrowAndAbort() {
let testCmd = '';
if (!isWindows) {
Expand Down
45 changes: 22 additions & 23 deletions test/internet/test-dns-ipv6.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,18 @@ TEST(async function test_lookup_ipv6_explicit(done) {
checkWrap(req);
});

/* This ends up just being too problematic to test
TEST(function test_lookup_ipv6_implicit(done) {
var req = dns.lookup(addresses.INET6_HOST, function(err, ip, family) {
assert.ifError(err);
assert.ok(net.isIPv6(ip));
assert.strictEqual(family, 6);
// This ends up just being too problematic to test
// TEST(function test_lookup_ipv6_implicit(done) {
// var req = dns.lookup(addresses.INET6_HOST, function(err, ip, family) {
// assert.ifError(err);
// assert.ok(net.isIPv6(ip));
// assert.strictEqual(family, 6);

done();
});
// done();
// });

checkWrap(req);
});
*/
// checkWrap(req);
// });

TEST(async function test_lookup_ipv6_explicit_object(done) {
function validateResult(res) {
Expand Down Expand Up @@ -233,15 +232,15 @@ TEST(function test_lookupservice_ip_ipv6(done) {
checkWrap(req);
});

/* Disabled because it appears to be not working on linux. */
/* TEST(function test_lookup_localhost_ipv6(done) {
var req = dns.lookup('localhost', 6, function(err, ip, family) {
assert.ifError(err);
assert.ok(net.isIPv6(ip));
assert.strictEqual(family, 6);

done();
});

checkWrap(req);
}); */
// Disabled because it appears to be not working on Linux.
// TEST(function test_lookup_localhost_ipv6(done) {
// var req = dns.lookup('localhost', 6, function(err, ip, family) {
// assert.ifError(err);
// assert.ok(net.isIPv6(ip));
// assert.strictEqual(family, 6);
//
// done();
// });
//
// checkWrap(req);
// });
7 changes: 3 additions & 4 deletions test/internet/test-http-dns-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
/*
* Repeated requests for a domain that fails to resolve
* should trigger the error event after each attempt.
*/

// Repeated requests for a domain that fails to resolve
// should trigger the error event after each attempt.

const common = require('../common');
const assert = require('assert');
Expand Down
42 changes: 21 additions & 21 deletions test/node-api/test_make_callback/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ assert.strictEqual(makeCallback(this,

// TODO(node-api): napi_make_callback needs to support
// strings passed for the func argument
/*
const recv = {
one: common.mustCall(function() {
assert.strictEqual(0, arguments.length);
assert.strictEqual(this, recv);
return 42;
}),
two: common.mustCall(function(x) {
assert.strictEqual(1, arguments.length);
assert.strictEqual(this, recv);
assert.strictEqual(x, 1337);
return 42;
}),
};
//
// const recv = {
// one: common.mustCall(function() {
// assert.strictEqual(0, arguments.length);
// assert.strictEqual(this, recv);
// return 42;
// }),
// two: common.mustCall(function(x) {
// assert.strictEqual(1, arguments.length);
// assert.strictEqual(this, recv);
// assert.strictEqual(x, 1337);
// return 42;
// }),
// };
//
// assert.strictEqual(makeCallback(recv, 'one'), 42);
// assert.strictEqual(makeCallback(recv, 'two', 1337), 42);
//
// // Check that callbacks on a receiver from a different context works.
// const foreignObject = vm.runInNewContext('({ fortytwo() { return 42; } })');
// assert.strictEqual(makeCallback(foreignObject, 'fortytwo'), 42);

assert.strictEqual(makeCallback(recv, 'one'), 42);
assert.strictEqual(makeCallback(recv, 'two', 1337), 42);

// Check that callbacks on a receiver from a different context works.
const foreignObject = vm.runInNewContext('({ fortytwo() { return 42; } })');
assert.strictEqual(makeCallback(foreignObject, 'fortytwo'), 42);
*/

// Check that the callback is made in the context of the receiver.
const target = vm.runInNewContext(`
Expand Down
10 changes: 4 additions & 6 deletions test/parallel/test-buffer-parent-property.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

/*
* Fix for https://github.com/nodejs/node/issues/8266
*
* Zero length Buffer objects should expose the `buffer` property of the
* TypedArrays, via the `parent` property.
*/
// Fix for https://github.com/nodejs/node/issues/8266
//
// Zero length Buffer objects should expose the `buffer` property of the
// TypedArrays, via the `parent` property.
require('../common');
const assert = require('assert');

Expand Down
12 changes: 5 additions & 7 deletions test/parallel/test-buffer-writeuint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
require('../common');
const assert = require('assert');

/*
* We need to check the following things:
* - We are correctly resolving big endian (doesn't mean anything for 8 bit)
* - Correctly resolving little endian (doesn't mean anything for 8 bit)
* - Correctly using the offsets
* - Correctly interpreting values that are beyond the signed range as unsigned
*/
// We need to check the following things:
// - We are correctly resolving big endian (doesn't mean anything for 8 bit)
// - Correctly resolving little endian (doesn't mean anything for 8 bit)
// - Correctly using the offsets
// - Correctly interpreting values that are beyond the signed range as unsigned

{ // OOB
const data = Buffer.alloc(8);
Expand Down
8 changes: 3 additions & 5 deletions test/parallel/test-child-process-cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ tmpdir.refresh();
const assert = require('assert');
const { spawn } = require('child_process');

/*
Spawns 'pwd' with given options, then test
- whether the exit code equals expectCode,
- optionally whether the trimmed stdout result matches expectData
*/
// Spawns 'pwd' with given options, then test
// - whether the exit code equals expectCode,
// - optionally whether the trimmed stdout result matches expectData
function testCwd(options, expectCode = 0, expectData) {
const child = spawn(...common.pwdCommand, options);

Expand Down
16 changes: 7 additions & 9 deletions test/parallel/test-child-process-double-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ if (isWindows) {
echo = spawn('echo', ['hello\nnode\nand\nworld\n']);
}

/*
* grep and sed hang if the spawn function leaks file descriptors to child
* processes.
* This happens when calling pipe(2) and then forgetting to set the
* FD_CLOEXEC flag on the resulting file descriptors.
*
* This test checks child processes exit, meaning they don't hang like
* explained above.
*/
// If the spawn function leaks file descriptors to subprocesses, grep and sed
// hang.
// This happens when calling pipe(2) and then forgetting to set the
// FD_CLOEXEC flag on the resulting file descriptors.
//
// This test checks child processes exit, meaning they don't hang like
// explained above.


// pipe echo | grep
Expand Down
Loading