-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Cache match results for compound failures #1334
base: main
Are you sure you want to change the base?
Cache match results for compound failures #1334
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Does it make sense add timeout_if_not_debugging
in the same vein you've used in #1333? The difference in running those specs is incredible - from 200s to 0.1s.
Thank you.
@pirj Style-wise, I was wondering about where the best place to reset state might be. I put the reset logic directly in the match method. I noticed that for a different issue, you add a blank All your suggestions seem good to me, so I'll go ahead and make them. Thanks for the look. |
Where do helper functions go when they're used in multiple spec files? It seems that |
When a compound matcher fails, the failure message checks both sides of the match to determine how to display the failure match. When multiple compound matchers are chained, that means the match for each side of the compound matcher may be called repeatedly for exponential growth. To address this behavior, we can cache the match result for each side of the compound operator each time a match is executed. We need to reset the cache each time the match is executed because the matcher may be re-used for a different expectation.
af695c0
to
74fe79e
Compare
A perfect place for it 👍 |
Refactor `timeout_if_not_debugging` into `spec_helper` and use it in the compound matcher spec to limit the run time when testing long chains of compound matchers.
74fe79e
to
6359530
Compare
This commit updates the timeout limit from 0.1s to 0.2s. Hopefully that's enough headroom for ruby 1.8.7. |
@Lukom does this fix your case? |
fixes #1331
When a compound matcher fails, the failure message checks both sides of
the match to determine how to display the failure match. When multiple
compound matchers are chained, that means the match for each side of the
compound matcher may be called repeatedly for exponential growth.
To address this behavior, we can cache the match result for each side of
the compound operator each time a match is executed. We need to reset the
cache each time the match is executed because the matcher may be re-used
for a different expectation.
Added RSpec context timing before the patch:
Added RSpec context timing after the patch: