-
Notifications
You must be signed in to change notification settings - Fork 553
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
Don't call SimpleCov.result before checking SimpleCov.result? #674
Don't call SimpleCov.result before checking SimpleCov.result? #674
Conversation
…ess_result in order to avoid instantiating SimpleCov.result prior to performing the .result? check, as doing so guarantees that .result? will always return 'true'
…data isn't clobbered by SimpleCov.run_exit_tasks\!/.process_results
Re the failing test -- looks like the same error has happened in at least one prior Travis build. I have not been able reproduce the issue in the local |
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.
Hi there,
sorry for the long time to get back to you - life and all :) That seems like a good fix to me I'll restart the build with the fail and meditate a bit about it
Awesome -- thanks, @PragTob! FWIW, I ran |
Ping @PragTob :) |
So the error is intermittent but not order dependent. Fun |
Hey sorry, I took a bit of a break from simplecov. Looks good rereading it all. Thanks a ton for your contribution 💚 |
Update ruby-simplecov to 0.17.1. 0.17.1 (2019-09-16) =================== Bugfix release for problems with ParallelTests. ## Bugfixes * Avoid hanging with parallel_tests. See [#746](simplecov-ruby/simplecov#746) (thanks [@annaswims](https://github.com/annaswims)) 0.17.0 (2019-07-02) =================== Maintenance release with nice convenience features and important bugfixes. Notably this **will be the last release to support ruby versions that have reached their end of life**. Moving forward official CRuby support will be 2.4+ and JRuby support will be 9.1+. Older versions might still work but no guarantees. ## Enhancements * Per default filter hidden files and folders. See [#721](simplecov-ruby/simplecov#721) (thanks [Renuo AG](https://www.renuo.ch)) * Print the exit status explicitly when it's not a successful build so it's easier figure out SimpleCov failed the build in the output. See [#688](simplecov-ruby/simplecov#688) (thanks [@daemonsy](https://github.com/daemonsy)) ## Bugfixes * Avoid a premature failure exit code when setting `minimum_coverage` in combination with using [parallel_tests](https://github.com/grosser/parallel_tests). See [#706](simplecov-ruby/simplecov#706) (thanks [@f1sherman](https://github.com/f1sherman)) * Project roots with special characters no longer cause crashes. See [#717](simplecov-ruby/simplecov#717) (thanks [@deivid-rodriguez](https://github.com/deivid-rodriguez)) * Avoid continously overriding test results with manual `ResultMergere.store_results` usage. See [#674](simplecov-ruby/simplecov#674) (thanks [@tomeon](https://github.com/tomeon))
Encountered in infertux/bashcov#36.
In the following snippet,
SimpleCov.process_result
is called withSimpleCov.result
as the first parameter. Because of this, theSimpleCov.result?
check at the very beginning ofSimpleCov.process_result
will always returntrue
, as@result
was initialized by the precedingSimpleCov.result
call:https://github.com/colszowka/simplecov/blob/03a9f7fde44a9388580977e4002b4f6823c2b4cc/lib/simplecov.rb#L197-L224
Due to the misordering of the
.result
and.result?
calls, any code that (likebashcov
) stores results manually withResultMerger.store_result
will have its coverage data clobbered whenSimpleCov.result
callsSimpleCov::ResultMerger.store_result
(as long asSimpleCov.command_name
hasn't changed between the two.store_result
calls). See this Travis build, which contains the test case from this PR but not the code fix, for an illustration of the problem.This PR makes the call to
SimpleCov.process_result
conditional onSimpleCov.result?
returningtrue
, ensuring that existing data is overwritten only ifSimpleCov.result
has already been instantiated elsewhere.Thanks in advance for your consideration!