Skip to content
Closed
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
8 changes: 4 additions & 4 deletions test/sequential/test-net-response-size.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,19 +32,19 @@ const cp = require('child_process');
if (process.argv[2] === 'server') {
// Server

const server = net.createServer(function(conn) {
const server = net.createServer(common.mustCall(function(conn) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives a false sense of security. This is a child process and if the child process fails, it doesn't affect the test. You can see this if you add a 2 as the second argument to common.mustCall() so that it causes an assertion. It will print the assertion message, but the test still passes.

$ ./node test/sequential/test-net-response-size.jsServer running.server received 65536 bytesserver received 36864 bytesserver received 1 bytesMismatched <anonymous> function calls. Expected exactly 2, actual 1. at Proxy.mustCall (/Users/trott/io.js/test/common/index.js:329:10) at Object.<anonymous> (/Users/trott/io.js/test/sequential/test-net-response-size.js:35:42) at Module._compile (internal/modules/cjs/loader.js:1090:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1111:10) at Module.load (internal/modules/cjs/loader.js:955:32) at Function.Module._load (internal/modules/cjs/loader.js:796:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47
$ tools/test.py test/sequential/test-net-response-size.js[00:01|% 100|+ 1|- 0]: Done 
$ 

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is not so useful because common.mustcall() is enclosed in child process. Thanks for the replay and I will close the PR.

conn.on('data', function(data) {
console.log(`server received ${data.length} bytes`);
});

conn.on('close', function() {
server.close();
});
});
}));

server.listen(common.PORT, '127.0.0.1', function() {
server.listen(common.PORT, '127.0.0.1', common.mustCall(function() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as above.

$ ./node test/sequential/test-net-response-size.js Server running.server received 65536 bytesserver received 36864 bytesserver received 1 bytesMismatched <anonymous> function calls. Expected exactly 2, actual 1. at Proxy.mustCall (/Users/trott/io.js/test/common/index.js:329:10) at Object.<anonymous> (/Users/trott/io.js/test/sequential/test-net-response-size.js:45:50) at Module._compile (internal/modules/cjs/loader.js:1090:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1111:10) at Module.load (internal/modules/cjs/loader.js:955:32) at Function.Module._load (internal/modules/cjs/loader.js:796:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47
$ tools/test.py test/sequential/test-net-response-size.js[00:01|% 100|+ 1|- 0]: Done 
$

console.log('Server running.');
});
}));

} else {
// Client
Expand Down