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

common.mustCall() is added #34920

Closed
wants to merge 3 commits into from
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 number Diff line number Diff 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
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.js
Server running.
server received 65536 bytes
server received 36864 bytes
server received 1 bytes
Mismatched <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
Contributor Author

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
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 bytes
server received 36864 bytes
server received 1 bytes
Mismatched <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