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

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

‎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
constfork=require('child_process').fork;
2626
constnet=require('net');
2727

28-
// progress tracker
2928
functionProgressTracker(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
functiontestServer(callback){
9190

92-
// destroy server execute callback when done
91+
// Destroy server execute callback when done.
9392
constprogress=newProgressTracker(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
constconnections=newProgressTracker(4,progress.done.bind(progress));
103102
constclosed=newProgressTracker(4,progress.done.bind(progress));
104103

105-
// create server and send it to child
104+
// Create server and send it to child.
106105
constserver=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
functionmessageHandlers(msg){
120119

121120
if(msg.what==='listening'){
122-
// make connections
121+
// Make connections.
123122
letsocket;
124123
for(leti=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
functiontestSocket(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
constserver=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
constconnect=net.connect(server.address().port);
171170
letstore='';
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
letserverSuccess=false;
186185
letsocketSuccess=false;
187186
child.on('message',functiononReady(msg){

0 commit comments

Comments
 (0)