Conversation
Trott
left a comment
There was a problem hiding this comment.
Somewhat rubber-stamp-y LGTM if CI is green.
test/common.js
Outdated
There was a problem hiding this comment.
hmm.. the same basic thing can be accomplished using:
common.mustCall(fn, 0);
There was a problem hiding this comment.
It could. The whole point is to get beautiful assertion messages though. Using common.mustCall() would yield:
Mismatched <anonymous> function calls. Expected 0, actual 1.
There was a problem hiding this comment.
Additionally, common.mustCall(fn, 0) will only fail when the exit event is emitted on process. The version in this PR fails immediately. That could be very helpful for a test that otherwise will mysteriously time out because something is holding the event loop open indefinitely.
There was a problem hiding this comment.
Just to add my 2 cents I also think common.mustNotCall() makes it immediately obvious what you want to happen without needing the context to know that 0 will imply it should not be called.
test/common.js
Outdated
There was a problem hiding this comment.
Just to add my 2 cents I also think common.mustNotCall() makes it immediately obvious what you want to happen without needing the context to know that 0 will imply it should not be called.
test/common.js
Outdated
There was a problem hiding this comment.
Would it help to keep this function's name also as mustNotCall? Stacktrace would be better I guess.
test/common.js
Outdated
There was a problem hiding this comment.
Can we do something to prevent this from printing stuff like
AssertionError: [object Object]
when msg is not a string?
There was a problem hiding this comment.
On second thought I think this is not needed as the function (common.mustNotCall()) must be invoked explicitly and using a non-string argument probably doesn't make sense.
e28bb07 to
85a7794
Compare
thefourtheye
left a comment
There was a problem hiding this comment.
LGTM if the CI is happy
|
@nodejs/build @jbergstroem ... something is happening with the OSX build bot. Failing to start on every CI run |
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: nodejs#11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
85a7794 to
7dd82dd
Compare
|
Landing this since the only problem is the macOS CI, which I can verify locally. |
|
@cjihrig do you have time to backport this to |
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: #11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: nodejs#11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: nodejs#11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
|
This would need backport PRs to land in v6 and v4 ... there are several recent test changes that depend on this so a backport would be preferrable. |
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: #11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
|
backported to v6.x in bea0a6e |
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: nodejs/node#11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit adds a
mustNotCall()helper for testing. This provides an alternative to usingcommon.fail()as a callback, or creating a callback function for the sole purpose of callingcommon.fail().Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)