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

assert: fix misformatted error message #11254

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@Trott
Member

Trott commented Feb 9, 2017

Before: Missing expected exception..

Afer: Missing expected exception.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

assert

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Feb 9, 2017

Member

Technically semver-major because of the idiosyncratic way we have to be
super-careful with error messages. If anyone thinks it violates the
Locked API due to that, I won't argue the point. (Paging @ChALkeR!)

My thinking is that this doesn't violate the Locked API because it's a bug fix, even if we have a policy (at least at this time) to treat this particular type of bug fix like it's semver major.

But a "sorry, semver major is semver major, deal with it" approach also makes sense. (In which case, I might see if there's a general sentiment to unlock the API but that's another conversation.)

Member

Trott commented Feb 9, 2017

Technically semver-major because of the idiosyncratic way we have to be
super-careful with error messages. If anyone thinks it violates the
Locked API due to that, I won't argue the point. (Paging @ChALkeR!)

My thinking is that this doesn't violate the Locked API because it's a bug fix, even if we have a policy (at least at this time) to treat this particular type of bug fix like it's semver major.

But a "sorry, semver major is semver major, deal with it" approach also makes sense. (In which case, I might see if there's a general sentiment to unlock the API but that's another conversation.)

@gibfahn

This comment has been minimized.

Show comment
Hide comment
@gibfahn

gibfahn Feb 9, 2017

Member

LGTM, and definitely seems related to #11200.

Member

gibfahn commented Feb 9, 2017

LGTM, and definitely seems related to #11200.

@cjihrig

cjihrig approved these changes Feb 9, 2017

@jasnell

jasnell approved these changes Feb 9, 2017

Show outdated Hide outdated lib/assert.js
@@ -342,7 +342,7 @@ function _throws(shouldThrow, block, expected, message) {
actual = _tryBlock(block);
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
(message ? ' ' + message : '');

This comment has been minimized.

@lpinca

lpinca Feb 10, 2017

Member

shouldn't this end with . when message is truthy?

(message ? ` ${message}.` : '');
@lpinca

lpinca Feb 10, 2017

Member

shouldn't this end with . when message is truthy?

(message ? ` ${message}.` : '');

This comment has been minimized.

@Trott

Trott Feb 10, 2017

Member

Yes, unless message is expected to already end with ., so ¯\(ツ)/¯. And there should also be a : rather than . after expected if message is truthy.

Thinking about this some more and looking at the uses, I wonder if the thing to do is get rid of all the logic for appending . in the first place. Nothing else appends .. And this mostly only seems to do it wrong!

Current master results in messages like this:

AssertionError: Missing expected exception..
AssertionError: Missing expected exception. foo bar baz

wat?

Compare to assert.strictEqual() which does not append .:

AssertionError: 'a' === 'b'
AssertionError: foo bar baz
@Trott

Trott Feb 10, 2017

Member

Yes, unless message is expected to already end with ., so ¯\(ツ)/¯. And there should also be a : rather than . after expected if message is truthy.

Thinking about this some more and looking at the uses, I wonder if the thing to do is get rid of all the logic for appending . in the first place. Nothing else appends .. And this mostly only seems to do it wrong!

Current master results in messages like this:

AssertionError: Missing expected exception..
AssertionError: Missing expected exception. foo bar baz

wat?

Compare to assert.strictEqual() which does not append .:

AssertionError: 'a' === 'b'
AssertionError: foo bar baz

This comment has been minimized.

@Trott

Trott Feb 10, 2017

Member

@lpinca OK, I just pushed some improvements based on your comment. PTAL

@Trott

Trott Feb 10, 2017

Member

@lpinca OK, I just pushed some improvements based on your comment. PTAL

Trott added some commits Feb 9, 2017

assert: fix misformatted error message
Before: `Missing expected exception..`

Afer: `Missing expected exception.`
@lpinca

lpinca approved these changes Feb 10, 2017

@lpinca

This comment has been minimized.

Show comment
Hide comment
@lpinca

lpinca Feb 10, 2017

Member

@Trott

Thinking about this some more and looking at the uses, I wonder if the thing to do is get rid of all the logic for appending . in the first place.

This also makes sense imo, I think most error messages don't use . at all.

Member

lpinca commented Feb 10, 2017

@Trott

Thinking about this some more and looking at the uses, I wonder if the thing to do is get rid of all the logic for appending . in the first place.

This also makes sense imo, I think most error messages don't use . at all.

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Feb 10, 2017

Member

I'm going to apply the blocked label to this until #11304 lands or there's some other satisfactory resolution for #11200.

Member

Trott commented Feb 10, 2017

I'm going to apply the blocked label to this until #11304 lands or there's some other satisfactory resolution for #11200.

@Trott Trott added the blocked label Feb 10, 2017

@jasnell

This comment has been minimized.

Show comment
Hide comment

@Trott Trott removed the blocked label Feb 15, 2017

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Feb 15, 2017

Member

assert is now Stable rather than Locked so this is un-blocked.

Member

Trott commented Feb 15, 2017

assert is now Stable rather than Locked so this is un-blocked.

Trott added a commit to Trott/io.js that referenced this pull request Feb 15, 2017

assert: fix misformatted error message
Before: `Missing expected exception..`

Afer: `Missing expected exception.`

PR-URL: nodejs#11254
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Feb 15, 2017

Member

Landed in 0af4183

Member

Trott commented Feb 15, 2017

Landed in 0af4183

@Trott Trott closed this Feb 15, 2017

@jasnell jasnell referenced this pull request Apr 4, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment