Skip to content

Conversation

@Tiriel
Copy link
Contributor

@Tiriel Tiriel commented Dec 24, 2017

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-bot nodejs-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
Contributor Author

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
Contributor Author

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:

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

Nice trick with require.resolve though :)

Copy link
Contributor Author

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 Tiriel force-pushed the test-missing-error branch from 3c3ffe8 to 3976872 Compare December 24, 2017 12:56
@Tiriel
Copy link
Contributor Author

Tiriel commented Dec 24, 2017

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
Contributor Author

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

@Trott Trott 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

Trott commented Dec 24, 2017

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 Tiriel force-pushed the test-missing-error branch from 3976872 to ea3c32e Compare December 25, 2017 07:55
@Tiriel
Copy link
Contributor Author

Tiriel commented Dec 25, 2017

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 Tiriel force-pushed the test-missing-error branch from ea3c32e to 398246f Compare December 27, 2017 08:52
@Tiriel
Copy link
Contributor Author

Tiriel commented Dec 27, 2017

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

@TimothyGu TimothyGu 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

jasnell commented Dec 28, 2017

@Tiriel
Copy link
Contributor Author

Tiriel commented Dec 29, 2017

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

jasnell commented Dec 29, 2017

CI failures are unrelated.

@maclover7
Copy link
Contributor

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

@TimothyGu TimothyGu 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: #17848
Fixes: #17148
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@apapirovski
Copy link
Contributor

Landed in 30892c8

@apapirovski apapirovski closed this Jan 3, 2018
@MylesBorins
Copy link
Contributor

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

@Tiriel
Copy link
Contributor Author

Tiriel commented Jan 10, 2018

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

@targos
Copy link
Member

targos commented Jan 10, 2018

@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
Contributor Author

Tiriel commented Jan 10, 2018

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#17848
Fixes: nodejs#17148
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@TimothyGu TimothyGu 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: #17848
Fixes: #17148
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Issues 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