Skip to content

Make RunContexts more consistent - #1846

Merged
leonard84 merged 3 commits into
spockframework:masterfrom
leonard84:make-run-contexts-more-resilient
Dec 13, 2023
Merged

leonard84 merged 3 commits into
spockframework:masterfrom
leonard84:make-run-contexts-more-resilient

Conversation

@leonard84

Copy link
Copy Markdown
Member

No description provided.

@leonard84 leonard84 self-assigned this Dec 13, 2023
@leonard84
leonard84 requested a review from AndreasTu December 13, 2023 11:06
@codecov

codecov Bot commented Dec 13, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (4da5b22) 80.33% compared to head (90ab779) 80.33%.

Files Patch % Lines
...in/java/org/spockframework/runtime/RunContext.java 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1846      +/-   ##
============================================
- Coverage     80.33%   80.33%   -0.01%     
- Complexity     4239     4242       +3     
============================================
  Files           434      434              
  Lines         13285    13300      +15     
  Branches       1688     1692       +4     
============================================
+ Hits          10672    10684      +12     
- Misses         1974     1976       +2     
- Partials        639      640       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +239 to +244
if (!runContexts.contains(this)) {
// something weird happened, and we got the got a separate RunContext hierarchy from what we'd expect
// maybe some thread re-use between runs
runContexts.clear();
runContexts.add(this);
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seams a bit too much to always asks for contains, which will traverse the whole linked list, and after that we traverse again. Isn't there a better way to do that?

Or maybe this is premature opt from my side, because are there many RunContexts anyway?

@leonard84 leonard84 Dec 13, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think in the wild it is 99.9% just one context.
And for Spock it is 99.0% 1 and 1% with 2.
And it should be the first element if nothing has gone wrong.

I've added an early return if everything is as it should be.

@leonard84

Copy link
Copy Markdown
Member Author

@leonard84
leonard84 enabled auto-merge (squash) December 13, 2023 16:23
@leonard84
leonard84 disabled auto-merge December 13, 2023 16:23
@leonard84
leonard84 merged commit e3a6436 into spockframework:master Dec 13, 2023
@leonard84
leonard84 deleted the make-run-contexts-more-resilient branch December 13, 2023 16:23
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.

2 participants