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

Migration from tap to mocha #2851

Merged
merged 2 commits into from
Jun 5, 2023

Conversation

StefanStojanovic
Copy link
Contributor

@StefanStojanovic StefanStojanovic commented May 17, 2023

Checklist
  • npm install && npm test passes
  • tests are included
  • commit message follows commit guidelines
Description of change

After the make-fetch-happen update in 02480f6, GitHub Actions started failing. Migrating from tap to mocha testing framework as issues only happened in GitHub Actions (tested locally with various node/python combinations, didn't reproduce any failures). This PR is made based on investigation and work done in #2837 as the simplest and probably the cleanest solution. With these changes, Mocha replaces tap completely, thus restoring GitHub Actions stability.

@StefanStojanovic StefanStojanovic marked this pull request as ready for review May 17, 2023 12:36
@rvagg
Copy link
Member

rvagg commented May 22, 2023

Still using tap for writing tests, mocha is used only for execution

Yeah, I don't think that's a good idea. The files are runnable by themselves, and will execute as soon as they are loaded into process, so all mocha is doing is acting as a "load these files" engine.

Actually rewriting the tests to Mocha+Chai (or similar) might be a decent path forward though, I know we've got a bit stuck with tap a few times.

@StefanStojanovic
Copy link
Contributor Author

Thanks for that information. I didn't want to rewrite tests initially as I did not know if that is the direction we want to go in. Since it is, I'll change the tests as well.

@StefanStojanovic
Copy link
Contributor Author

Actually rewriting the tests to Mocha+Chai (or similar) might be a decent path forward though, I know we've got a bit stuck with tap a few times.

@rvagg I've rewritten tests. I haven't used chai because assert was more than enough for what I needed. I've also made a custom mocha reporter in 436cc18 which, at first, I used for development, but it ended up being useful for the detailed test report. Potentially we can stick with it, but I'm also OK with using something prebuilt and less verbose like the tap reporter.

Regarding the PR, I'm still keeping it as a draft because I want #2650 and #2846 to land first so I can change those tests too, and not leave it to the people who opened those PRs to make needed changes. Besides waiting for those PRs, I consider this work completed.

P.S. GitHub makes it look like there are very big changes, but most of them are just indentation and changes from tap to assert. It could be easier for reviewers to use some 3rd party tools such as KDiff3.

@StefanStojanovic StefanStojanovic force-pushed the mefi-github-actions-mocha branch 3 times, most recently from 9fb124f to 7a05cfc Compare May 25, 2023 17:15
@StefanStojanovic StefanStojanovic marked this pull request as ready for review May 25, 2023 18:53
@StefanStojanovic
Copy link
Contributor Author

@dennisameling and @dsanders11 when you get time, please review the changes I made to the tests you added in #2650 and #2846 respectively. They were supposed to be just changed from tap to mocha, but if I made some other unintended change let me know.

@dsanders11
Copy link
Contributor

@StefanStojanovic, parallel install tests refactor to mocha LGTM.

@dennisameling
Copy link
Contributor

Refactor of the VS2022 tests LGTM ✅️ thank you!

After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.
Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
@cclauss
Copy link
Contributor

cclauss commented May 26, 2023

Will we do a similar migration in the testing of Node.js?

Will we be able to drop tap2junit?

@rvagg
Copy link
Member

rvagg commented May 29, 2023

so for background: tap2junit is used for nice test feedback in jenkins - you can run these tests in ci.nodejs.org and get nice output

mocha can do tap output if you want, but none of this is essential, it could all be ditched I think and just get nice mocha output 🤷

@StefanStojanovic
Copy link
Contributor Author

Will we do a similar migration in the testing of Node.js?

There is no plan to do that for Node.js tests as they are working well.

Will we be able to drop tap2junit?

These tests are run through GitHub Actions, tap2junit is not used here.

@rvagg
Copy link
Member

rvagg commented May 30, 2023

These tests are run through GitHub Actions, tap2junit is not used here.

See https://ci.nodejs.org/view/All/search/?q=gyp

@cclauss
Copy link
Contributor

cclauss commented May 30, 2023

Should these changes be landed on https://github.com/nodejs/gyp-next first?

@StefanStojanovic
Copy link
Contributor Author

See https://ci.nodejs.org/view/All/search/?q=gyp

Are those jobs still in use? They seem outdated and have no build history. Also, I've only seen GitHub Actions in node-gyp repo PRs

Should these changes be landed on https://github.com/nodejs/gyp-next first?

I do not know what you mean by this, since these changes change node-gyp tests. From what I saw (went through it very briefly) gyp-next has a node-gyp integration workflow that runs node-gyp tests (and for that reason is in red lately), but it uses this repo, so landing this PR here should manifest there as well. If you had something else in mind please let me know.

@rvagg
Copy link
Member

rvagg commented May 31, 2023

https://ci.nodejs.org/job/nodegyp-test-pull-request/

One of the benefits of this is the ability to test a broader range of Node versions and platform permutations than CI allows; which is helpful for a project that depends so much on OS-level inputs like node-gyp does. It hasn't been used much recently because the people that might have used it have slowly faded away, leaving us with CI.
I'm not suggesting it be retained as an important piece of functionality, or block the work here, just maybe not forgotten as a thing of value to maybe utilise or integrate in the CI process at some point.

@StefanStojanovic
Copy link
Contributor Author

Since we've been discussing this PR for some time, and I see no clear objections to the proposed changes, I just wanted to ask if there's something else I should do to get it approved.

@cclauss cclauss merged commit 5df2b72 into nodejs:main Jun 5, 2023
cclauss pushed a commit to cclauss/node-gyp that referenced this pull request Jun 13, 2023
* migrate from tap to mocha

After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.

* write custom test reporter for more verbose output

Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
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.

5 participants