Skip to content

Conversation

@Tiriel
Copy link
Contributor

Merry christmas!

Test test-require-deps-deprecation.js was failing when user already had node
installed with acorn in require.resolve range.
Modified test to acknowledge the possibility and throw only if acorn is
found in the deps directory.

Fixes: #17148
Refs: #17148 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Dec 24, 2017
Copy link
Member

Choose a reason for hiding this comment

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

This wouldn't be necessary.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Do you mean the comment, or the 'foo' dep too?

Copy link
Member

Choose a reason for hiding this comment

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

The “foo” dep… and as a result the comment too.

Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't think we ever use the $e convention. err is fine.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Damn, sorry, too much PHP lately I think...

Copy link
Member

Choose a reason for hiding this comment

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

To avoid comparing things to the empty string this could be refactored as:

letpath;try{path=require.resolve(m);}catch(err){continue;}assert.notStrictEqual(path,m);

Nice trick with require.resolve though :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks! Correcting ASAP.

All credit should go to @Trott though ;)

@Tiriel
Copy link
ContributorAuthor

Done! Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Two small nits:

  • /node/deps looks like a path, so maybe just a build-in module?
  • Can you add Ref: https://github.com/nodejs/node/issues/17148 to this comment or something like that? Give people a link so they can see the bug that this approach avoids that the simpler approach being replaced doesn't.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

True! It's done

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Maybe restore the error message checking in the catch block?

assert.ok(err.toString().startsWith('Error: Cannot find module ')`

Copy link
Member

@TrottTrott left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@Trott
Copy link
Member

Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. Fixes: nodejs#17148 Refs: nodejs#17148 (comment)
@Tiriel
Copy link
ContributorAuthor

Done! Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Missing period

Copy link
Member

Choose a reason for hiding this comment

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

I’d still like to see a continue here to avoid unneeded assertion in the following line.

Fix following review. Reinstated assertion on error message, and corrected comment. Leaving continu to break loop and avoid unneeded assertions. Fixes: nodejs#17148 Refs: nodejs#17148 (comment)
@Tiriel
Copy link
ContributorAuthor

Sorry for the delay, I was traveling!
I fixed following return, although the diff didn't disappear for some reason... I think I amended my commit instead of simple adding one.

Copy link
Member

@TimothyGuTimothyGu left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for staying with this through the back and forth. I think the comment doesn't disappear as it is technically on a line that still exists in its entirety.

@jasnell
Copy link
Member

@Tiriel
Copy link
ContributorAuthor

Are these tests know to be this long/to fail, or is there some thing I can fix on my end?

@jasnell
Copy link
Member

CI failures are unrelated.

@maclover7
Copy link
Contributor

CI: https://ci.nodejs.org/job/node-test-pull-request/12380/

@TimothyGuTimothyGu added dont-land-on-v4.x author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jan 3, 2018
apapirovski pushed a commit that referenced this pull request Jan 3, 2018
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. PR-URL: #17848Fixes: #17148 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
@apapirovski
Copy link
Contributor

Landed in 30892c8

@MylesBorins
Copy link
Contributor

This does not land cleanly on v9.x, could it be backported?

@Tiriel
Copy link
ContributorAuthor

If it's something I can do myself, I'll gladly give it a try!

@targos
Copy link
Member

@Tiriel thanks! The goal would be to checkout a new branch based on upstream/v9.x-staging and one of:

  • cherry-pick this commit and fix conflicts, then open a new PR
  • rewrite the change if it has to be very different, then open a new PR
  • ask us to change the label to "dont-land-on-v9.x" if it is not relevant to this branch

See https://github.com/nodejs/node/blob/master/doc/guides/backporting-to-release-lines.md for the full guide.

@Tiriel
Copy link
ContributorAuthor

Thanks, I was precisely reading this guide and following it 😄

I'll try these solutions in this order.

Tiriel added a commit to Tiriel/node that referenced this pull request Jan 10, 2018
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. Also changed the deprecation test for v9.x: common.expectWarning was failing because the required deps now throw ReferenceErrors when not properly called internally in the right order. PR-URL: nodejs#17848Fixes: nodejs#17148 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
@TimothyGuTimothyGu removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 13, 2018
MylesBorins pushed a commit that referenced this pull request Feb 20, 2018
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. Also changed the deprecation test for v9.x: common.expectWarning was failing because the required deps now throw ReferenceErrors when not properly called internally in the right order. Bacport-PR-URL: #18077 PR-URL: #17848Fixes: #17148 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Feb 21, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: missing expected exception in parallel/test-require-deps-deprecation.js

10 participants

@Tiriel@Trott@jasnell@maclover7@apapirovski@MylesBorins@targos@TimothyGu@cjihrig@nodejs-github-bot