Skip to content

Commit 443d60a

Browse files
Trotttargos
authored andcommitted
test: use log only in test-child-process-fork-net
We are currently having issues with test-child-process-fork-net on Windows CI. Debugging is slightly hampered by the mix of `console.log()` and `console.error()` as our test runner does not interleave stdout and stderr, so the order of output is not preserved. Change the sole instance of `console.error()` to `console.log()` to improve debugability. While editing, I also took the opportunity to add capitalization and punctuation to comments (as that is a nit we see from time to time and there is a potential ESLint rule to enforce the capitalization part). PR-URL: #20873 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent ed84b7d commit 443d60a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

test/parallel/test-child-process-fork-net.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const assert = require('assert');
2525
const fork = require('child_process').fork;
2626
const net = require('net');
2727

28-
// progress tracker
2928
function ProgressTracker(missing, callback) {
3029
this.missing = missing;
3130
this.callback = callback;
@@ -54,7 +53,7 @@ if (process.argv[2] === 'child') {
5453
socket.destroy();
5554
});
5655

57-
// start making connection from parent
56+
// Start making connection from parent.
5857
console.log('CHILD: server listening');
5958
process.send({ what: 'listening' });
6059
});
@@ -86,10 +85,10 @@ if (process.argv[2] === 'child') {
8685
assert.strictEqual(code, 0, message);
8786
}));
8887

89-
// send net.Server to child and test by connecting
88+
// Send net.Server to child and test by connecting.
9089
function testServer(callback) {
9190

92-
// destroy server execute callback when done
91+
// Destroy server execute callback when done.
9392
const progress = new ProgressTracker(2, function() {
9493
server.on('close', function() {
9594
console.log('PARENT: server closed');
@@ -98,11 +97,11 @@ if (process.argv[2] === 'child') {
9897
server.close();
9998
});
10099

101-
// we expect 4 connections and close events
100+
// We expect 4 connections and close events.
102101
const connections = new ProgressTracker(4, progress.done.bind(progress));
103102
const closed = new ProgressTracker(4, progress.done.bind(progress));
104103

105-
// create server and send it to child
104+
// Create server and send it to child.
106105
const server = net.createServer();
107106
server.on('connection', function(socket) {
108107
console.log('PARENT: got connection');
@@ -115,11 +114,11 @@ if (process.argv[2] === 'child') {
115114
});
116115
server.listen(0);
117116

118-
// handle client messages
117+
// Handle client messages.
119118
function messageHandlers(msg) {
120119

121120
if (msg.what === 'listening') {
122-
// make connections
121+
// Make connections.
123122
let socket;
124123
for (let i = 0; i < 4; i++) {
125124
socket = net.connect(server.address().port, function() {
@@ -143,11 +142,11 @@ if (process.argv[2] === 'child') {
143142
child.on('message', messageHandlers);
144143
}
145144

146-
// send net.Socket to child
145+
// Send net.Socket to child.
147146
function testSocket(callback) {
148147

149-
// create a new server and connect to it,
150-
// but the socket will be handled by the child
148+
// Create a new server and connect to it,
149+
// but the socket will be handled by the child.
151150
const server = net.createServer();
152151
server.on('connection', function(socket) {
153152
socket.on('close', function() {
@@ -159,14 +158,14 @@ if (process.argv[2] === 'child') {
159158
console.log('PARENT: server closed');
160159
callback();
161160
});
162-
// don't listen on the same port, because SmartOS sometimes says
161+
// Don't listen on the same port, because SmartOS sometimes says
163162
// that the server's fd is closed, but it still cannot listen
164163
// on the same port again.
165164
//
166165
// An isolated test for this would be lovely, but for now, this
167166
// will have to do.
168167
server.listen(0, function() {
169-
console.error('testSocket, listening');
168+
console.log('testSocket, listening');
170169
const connect = net.connect(server.address().port);
171170
let store = '';
172171
connect.on('data', function(chunk) {
@@ -181,7 +180,7 @@ if (process.argv[2] === 'child') {
181180
});
182181
}
183182

184-
// create server and send it to child
183+
// Create server and send it to child.
185184
let serverSuccess = false;
186185
let socketSuccess = false;
187186
child.on('message', function onReady(msg) {

0 commit comments

Comments
 (0)