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

Have the global timeout take into account t.timeout() durations #2758

Merged
merged 12 commits into from Jun 19, 2021
Merged

Have the global timeout take into account t.timeout() durations #2758

merged 12 commits into from Jun 19, 2021

Conversation

OhYash
Copy link
Contributor

@OhYash OhYash commented May 27, 2021

This PR attempts to allow tests to run beyond the global limit (which is 10s default).
See #2384 for details.

Tests cases and documentation pending until the debounce() wait period can be overridden.

Copy link
Member

@novemberborn novemberborn 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 turning this into a PR!

You're right that debounce() isn't a direct fit for this. It's perhaps also unnecessary now that we can use https://nodejs.org/docs/latest-v12.x/api/timers.html#timers_timeout_refresh. But maybe that's beside the point.

I don't think the timeout has to be accurate. The goal is for the global timeout to not fire when a test is waiting for a longer period. Perhaps we can think of these t.timeout() calls as preventing the global timeout from firing. We can compute the timestamp before which, if it fires, it should simply restart the timer. What do you think?

lib/api.js Outdated Show resolved Hide resolved
lib/runner.js Outdated Show resolved Hide resolved
lib/runner.js Outdated Show resolved Hide resolved
@OhYash
Copy link
Contributor Author

OhYash commented Jun 2, 2021

I've updated the api.js to skip global timeout from getting fired in case an individual test timeout is defined.

  • Updated some bits for existing tests to still pass.

If this approach looks good, I'll proceed with adding fresh tests specific to the new changes.

This still leaves debounce() limitations to be fixed later. So parallel running tests are more likely to succeed even beyond their timeout limits.

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

Thanks @OhYash! I've pushed some small changes (and merged main). CI is a bit choppy now but some runs should pass…

lib/api.js Outdated Show resolved Hide resolved
@OhYash OhYash marked this pull request as ready for review June 14, 2021 07:10
@OhYash
Copy link
Contributor Author

OhYash commented Jun 14, 2021

Thanks @novemberborn for fixing some of the unnecessary changes I've made. I've fixed the CI tests and added one api.js test

@OhYash
Copy link
Contributor Author

OhYash commented Jun 18, 2021

Added a test for stateChange event emitted by notifyTimeoutUpdate

@novemberborn novemberborn linked an issue Jun 19, 2021 that may be closed by this pull request
@novemberborn novemberborn changed the title Override timeout beyond global limit for individual tests Have the global timeout take into account t.timeout() durations Jun 19, 2021
@novemberborn novemberborn merged commit 35994d4 into avajs:main Jun 19, 2021
@novemberborn
Copy link
Member

Thanks @OhYash!

@OhYash
Copy link
Contributor Author

OhYash commented Jun 19, 2021

Finally! After me stretching it for too long 😅.
Thanks for help, @novemberborn !!

@mikob
Copy link

mikob commented Jul 6, 2021

Thank you @OhYash! @novemberborn will this be included in a release soon? Seems like there hasn't been a release since January.

@novemberborn
Copy link
Member

@mikob we're working towards AVA 4. I'm hoping to put another prerelease of that out soon.

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.

Have the global timeout take into account t.timeout() durations
3 participants