Skip to content
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

fix(node): Enable native node tests #695

Merged
merged 36 commits into from
Feb 10, 2021
Merged

fix(node): Enable native node tests #695

merged 36 commits into from
Feb 10, 2021

Conversation

Soremwar
Copy link
Contributor

@Soremwar Soremwar commented Feb 2, 2021

No description provided.

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2021

CLA assistant check
All committers have signed the CLA.

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 2, 2021

This will implement https://github.com/Soremwar/deno_node_tests

This is gonna be a big refactor, many tests won't be enabled as of now due to possible incompatibilities between the node lib and /std/node but luckily I designed the test script to be very configurable allowing to us to choose what tests to bring in

@ry
Copy link
Member

ry commented Feb 2, 2021

Sorry I'm a bit confused about the purpose of this. Can you explain more what you had in mind?

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 2, 2021

This will allow us to test std/node with the actual test suite the node folks use in their repo. This should help catch any implementation bugs or lack of features that the current library might have (I know for a fact this kind of inconsistencies are present in the Buffer implementation)

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 3, 2021

I'm done for the night, I need to actually find some tests we can enable to start using this but it should be good to go for review

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 3, 2021

BTW How should we handle the node license here? I can append the MIT license to the top of each file but IDK if that's enough

@ry
Copy link
Member

ry commented Feb 3, 2021

Regarding license, you do not need to include the full text of the license at the top of each file, just a single line

// Copyright Joyent and Node contributors. All rights reserved. MIT license.

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 3, 2021

Test suite functional and configurable, well documented and with the proper copyright headers.

Big plus, I just set up the first test and catched the first implementation inconsistency (a static method inside EventEmitter)

This is ready for review

Copy link
Contributor

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

Would prefer if this was more like regular tests and didn't require special steps to test.
WASI does this too with upstream tests but re-uses Deno.test.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
node/testdata/runner.ts Outdated Show resolved Hide resolved
node/testdata/runner.ts Outdated Show resolved Hide resolved

To enable new tests, simply add a new entry inside `node/testdata/config.json`
under the `tests` property. The structure this entries must have has to resemble
a path inside `https://github.com/nodejs/node/tree/master/test`.
Copy link
Member

@ry ry Feb 4, 2021

Choose a reason for hiding this comment

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

Have you considered including Node as a git submodule? Is it too big?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A git submodule could suffice, but it makes it harder to patch some files that are needed for this to work, namely common/index.js.

That file is used in pretty much every single file, however it uses things like child_process that are not needed in most cases, so instead I just patch it and all the tests that are enabled continue to use it without any trouble

Not to mention this is more user friendly than submodules :)

Copy link
Member

Choose a reason for hiding this comment

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

How about mocking common/index.js by injecting a fake module into require.cache, using a technique described here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might be more complicated than the current solution though @kt3k

node/testdata/test.ts Outdated Show resolved Hide resolved
@ry ry requested a review from kt3k February 8, 2021 16:53
node/testdata/setup.ts Outdated Show resolved Hide resolved
@kt3k
Copy link
Member

kt3k commented Feb 9, 2021

Tested locally. I was able to add test cases by adding items in config.json and running setup.ts 👍

setup.ts looks good to me. It requires the internet access, but that's only in the contributors' machine who want to change the node compatibility test. It doesn't affect CI and other contributors. setup.ts is also good in the sense it uses the fixed version of node.js and clear all the previously downloaded cases. So the result is deterministic and idempotent. I think there will be less (or no) confusions about updating these test cases.

BTW the directory name for these tools look a bit strange to me. I think we usually use testdata for just data for testing (like fixtures). Because setup.ts is the entrypoint for the developers, how about naming like /node/tools/setup.ts? @Soremwar

@ry
Copy link
Member

ry commented Feb 9, 2021

I also tested it locally and it works. I'm in favor of this change. Nice work @Soremwar!

BTW the directory name for these tools look a bit strange to me. I think we usually use testdata for just data for testing (like fixtures). Because setup.ts is the entrypoint for the developers, how about naming like /node/tools/setup.ts?

This also stood out to me. Non-fixture stuff should not be in testdata.

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 9, 2021

node/tools sounds good to me, just updated the test folder

@lucacasonato
Copy link
Member

Maybe node/_tools because it is internal?

@Soremwar
Copy link
Contributor Author

Soremwar commented Feb 9, 2021

_tools it is

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

LGTM 😁

@kt3k
Copy link
Member

kt3k commented Feb 10, 2021

@Soremwar Thank you for your contribution! Merging.

@kt3k kt3k merged commit d64c79f into denoland:main Feb 10, 2021
@Soremwar Soremwar deleted the node branch November 25, 2021 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants