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

test: add check in test-signal-handler #8248

Closed
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions test/parallel/test-signal-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ var i = 0;
setInterval(function() {
console.log('running process...' + ++i);

if (i == 5) {
if (i === 5) {
process.kill(process.pid, 'SIGUSR1');
}
}, 1);

// Test on condition where a watcher for SIGNAL
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
process.on('SIGHUP', function() {});
process.on('SIGHUP', function() { common.fail('should not run'); });
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap it with common.mustCall(), tho?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the function is called, the test has failed. It would be wrapped in a 'common.mustNotCall()' if we had one.

Copy link
Member

Choose a reason for hiding this comment

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

I would simply make this

process.on('SIGHUP', common.fail)

And just do without the should not run text.

Copy link
Member Author

@Trott Trott Aug 24, 2016

Choose a reason for hiding this comment

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

@jasnell Done that way, the AssertionError looks like this:

AssertionError: null undefined null
    at process.exports.fail (/Users/trott/io.js/test/common.js:438:10)
    at emitNone (events.js:91:20)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:199:44)

There are two things I don't like about that:

  • The stack trace does not show where the actual problem is. It does not mention the test file at all.
  • null undefined null: What?!

In contrast, done the way it is in this PR, it looks like this:

AssertionError: should not run
    at Object.exports.fail (/Users/trott/io.js/test/common.js:438:10)
    at process.<anonymous> (/Users/trott/io.js/test/parallel/test-signal-handler.js:32:42)
    at emitNone (events.js:91:20)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:199:44)

The stack trace includes the name of the test file and the line that resulted in the failure.

Copy link
Member

Choose a reason for hiding this comment

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

null undefined null is going to be my new catchphrase... sigh.. looks like we should tweak the output for common.fail

process.removeAllListeners('SIGHUP');
process.on('SIGHUP', common.mustCall(function() {}));
process.kill(process.pid, 'SIGHUP');