node icon indicating copy to clipboard operation
node copied to clipboard

test: add test for `Module._stat`

Open RaisinTen opened this issue 3 years ago • 6 comments

Module._stat landed in https://github.com/nodejs/node/pull/44537 without a test, so this change adds one.

Signed-off-by: Darshan Sen [email protected]

RaisinTen avatar Sep 18 '22 12:09 RaisinTen

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

nodejs-github-bot avatar Sep 18 '22 12:09 nodejs-github-bot

@aduh95 aren't mustCalls for making sure that a callback passed to a function gets called? This one's totally synchronous, that's why I tested this completely based on the change in return values.

RaisinTen avatar Sep 18 '22 12:09 RaisinTen

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

nodejs-github-bot avatar Sep 19 '22 00:09 nodejs-github-bot

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

nodejs-github-bot avatar Sep 19 '22 06:09 nodejs-github-bot

cc @nodejs/modules

ljharb avatar Sep 19 '22 15:09 ljharb

we need the loader hook API to stabilize

It’s pretty close. Once https://github.com/nodejs/node/pull/44710 and https://github.com/nodejs/node/pull/43772 land and we allow some time for baking, that’s all that’s on our list before declaring the API stable: https://github.com/nodejs/loaders#status

GeoffreyBooth avatar Sep 19 '22 16:09 GeoffreyBooth

To be clear, the PR that exposed Module._stat has already landed and it has been released to v18 and v16, I'm not sure why a test for such a thing wouldn't be accepted. Do y'all have suggestions on what needs to be changed in the test for it to be accepted? I don't think it's a good idea to have untested features laying around. If y'all are not happy that the feature exists, would y'all be acceptive of a PR that reverts https://github.com/nodejs/node/pull/44537?

RaisinTen avatar Oct 21 '22 14:10 RaisinTen

(As for reverting, I strongly object - I made the original PR for a reason, it shouldn't be reverted)

Where's the suggestion for reverting?

Even if we eventually revert (not that I'm suggesting we do) it would be preferable to revert both the feature and its test together, I think, so we have the history.

GeoffreyBooth avatar Oct 21 '22 16:10 GeoffreyBooth

@GeoffreyBooth

Where's the suggestion for reverting?

I posted the comment about reverting in https://github.com/nodejs/node/pull/44713#issuecomment-1287069974 in case we are not comfortable with exposing Module._stat.

Even if we eventually revert (not that I'm suggesting we do) it would be preferable to revert both the feature and its test together, I think, so we have the history.

Yes but for that we would need to land the test first. If you take a look at the contents of https://github.com/nodejs/node/pull/44537 you would see that it landed without any tests, which is why I thought of sending a PR to add some.

RaisinTen avatar Oct 22 '22 13:10 RaisinTen

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

nodejs-github-bot avatar Oct 22 '22 14:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 23 '22 10:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 25 '22 06:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 25 '22 09:10 nodejs-github-bot

Landed in 37b8a603f886634416046e337936e4c586f4ff58

nodejs-github-bot avatar Oct 25 '22 11:10 nodejs-github-bot