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

Allow manual merging #780

Merged
merged 11 commits into from Jan 17, 2020
Merged

Allow manual merging #780

merged 11 commits into from Jan 17, 2020

Conversation

deivid-rodriguez
Copy link
Collaborator

This my WIP version of #681. It would probably be better to keep the discussion in that PR, but to do that I would need permissions to push to @ticky's fork.

lib/simplecov.rb Outdated Show resolved Hide resolved
@deivid-rodriguez
Copy link
Collaborator Author

This should be ready now, I think?

I rebased the old PR and investigated and fixed the cucumber failures (with the help of cucumber/aruba#675). I also address some not yet addressed comments about the documentation from the previous PR.

@deivid-rodriguez
Copy link
Collaborator Author

Well, I'm now trying this in my app and it's not quite working as I expect. I need to have a closer look, so this is back to WIP.

@PragTob
Copy link
Collaborator

PragTob commented Dec 9, 2019

Thanks so much @deivid-rodriguez (and @ticky !) for this 💚 🎉 🚀

As it's WIP atm I haven't taken a look yet, will take one at another time but just wanted to express my gratitude 🤗

IMG_20181116_075339_01

@deivid-rodriguez
Copy link
Collaborator Author

Thanks for your encouraging and positive attitude :) I'll try to get this over the line!

@ticky
Copy link
Contributor

ticky commented Dec 9, 2019

Thanks for pushing ahead with this @deivid-rodriguez! Your changes are looking good to me - I’ll try them out in place of my branch and see if things still work as expected.

@deivid-rodriguez
Copy link
Collaborator Author

Ok, I think I fixed the issue. Previously results were being incorrectly merged using Hash#merge, and the ResultMerger.merge_results was being passed a single incorrectly merged result. Essentially the previous version was merging resultsets correctly at the file level, but not at the line level. See 4fedabd.

This now works as I expect against my library, I'll look into getting the last fix covered.

@deivid-rodriguez
Copy link
Collaborator Author

deivid-rodriguez commented Dec 10, 2019

@ticky Make sure you use the latest commit too. I think your different runners are correctly merging the set of files that they cover all together, but you might not be properly getting the set of lines covered for each file properly merged. So, I would expect the last commit to increase the total coverage in your application.

@ticky
Copy link
Contributor

ticky commented Dec 10, 2019

All working for us here on 4fedabd.

Looks like a minor change in coverage data reporting, but it seems about as expected.

Nice work @deivid-rodriguez :)

@PragTob
Copy link
Collaborator

PragTob commented Dec 11, 2019

@ticky thanks for testing this out! 💚

Really good work @deivid-rodriguez ! I have a (minor) knee surgery tomorrow, not sure if I get to look at this properly before ~Friday/Saturday so please excuse my tardyness but I really want to get this in :)

IMG_20181111_110737

@deivid-rodriguez
Copy link
Collaborator Author

@PragTob Hope your surgery goes well!

Regarding this PR, I still want to give it another look and try a few extra things, so no rush. Will let you know when I consider it ready for review!

@deivid-rodriguez
Copy link
Collaborator Author

Found one more issue where only the first command_name => coverage_data pair on each result set was getting merged. Fixed by 4d3492d.

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

Looking very good, thank you very much! Only very minor comments around.

IMG_20190215_122642_Bokeh

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
features/test_unit_collate.feature Show resolved Hide resolved
features/test_unit_collate.feature Show resolved Hide resolved
lib/simplecov.rb Outdated Show resolved Hide resolved
lib/simplecov.rb Outdated Show resolved Hide resolved
lib/simplecov.rb Show resolved Hide resolved
@PragTob
Copy link
Collaborator

PragTob commented Dec 15, 2019

The failing test is the JRuby flaky one I gotta take care off... chose to not rerun it as I figured you still wanted to update it here

@deivid-rodriguez
Copy link
Collaborator Author

Thanks for the review @PragTob!

I still want to fix some issues with the current implementation. For example, a correct merged report is now generated twice, one inline, and one in the at_exit hook, which is confusing at least. Then I wanted to have a look at test coverage and see how I can improve it. Now I'll also add "Address @PragTob's feedback" to the list :)

@PragTob
Copy link
Collaborator

PragTob commented Dec 15, 2019

Sounds like a plan! 👌

IMG_20191011_074652

@deivid-rodriguez
Copy link
Collaborator Author

deivid-rodriguez commented Jan 14, 2020

So I created some unit tests for this, but I run into several issues while creating them that I think might be related to #820. So I think I might've fixed that issue?

What I did was essentially making sure that when reading reports from disk into a hash, or manipulating them, all keys are always symbols. Do we have an regression scenario for #820? If so, I can extract the relevant changes from this PR into a separate PR, and add that regression test in there.

@PragTob
Copy link
Collaborator

PragTob commented Jan 14, 2020

@deivid-rodriguez is the last ticket reference to #802 a mistake and you wanted to do #820 ? If so then we almost have one, I started writing one (generated an old resultset.json, created a project for it etc) but then got sick and took a break 😁 If I don't feel worse tomorrow I'll likely finish it up tomorrow and will check against your branch. Although, imo it's likely that this isn't #820 as I think #820 has to do with the different file structure (extra level) not the keys being symbols.

On a slightly related note I was pondering removing the "symbolization" of keys as it seems to be a waste of memory & run time while we could us them without them being symbolized but I wanted to double check and see how far the symbolization goes.

@deivid-rodriguez
Copy link
Collaborator Author

Yes, I corrected the mistake now. I'm not sure it wasn't #820, but since I ended up removing the symbolize_names_of_coverage_results which is what's crashing there, I figure this issue might be gone.

Regarding removing the symbolization, I think that's a good move, yeah. I was about to do that to fix the issue I was having (some "file name" keys were symbols, and others string, so they wouln't merge fine). But I ended up symbolizing everywhere instead, since it looked simpler to achieve.

@deivid-rodriguez
Copy link
Collaborator Author

Oh, I also made this change: 93c771d, because branches: nil was sneaking into merged reports, even if none of the merged reports had any branch information in them. Hopefully it's correct?

@PragTob
Copy link
Collaborator

PragTob commented Jan 15, 2020

Yeah it crashed in the symbolization, but I think it'll then just crash somewhere else where it tries to traverse the tree - unless the time is old (meaning time in the resultset is after the timeout) in which case it wouldn't do that and I'd have to adjust my test :D

Not sure about the other commit, I'd have to check impact in other places. I think it's more in line with what normal Coverage returns so that's good - sometimes I prefer to have all keys but just have them be empty but... tradeoffs 🤷‍♂️

@PragTob
Copy link
Collaborator

PragTob commented Jan 15, 2020

@deivid-rodriguez so me trying to reproduce the failure is at the branch fix-crash-against-old-resultset-json but.. it passes. So it doesn't seem to be what I assumed it was (incompatibility with the old resultset.json) and it just runs against it and works. Maybe it's just not triggered or whatever the condition is isn't quite right in the test setup.

edit: yeah right now once we get to the code that blows up the old resultset.json had been overridden with a new one already 🤷‍♀️

edit2: ok if I don't let it store the result then it crashes like it does in the report, now to figure how to make that. I probably should comment on #820 though ;)

@PragTob
Copy link
Collaborator

PragTob commented Jan 16, 2020

@deivid-rodriguez Okay I double checked with #824 and it first it seemed that it solved the crash, but it then highlighted a couple of errors in my test setup that I need to fix up (the paths in the saved coverage.json need to be the same ones as the local machine and I need to update the time to not go beyond the merge timeout as your changes move the crash to that time). Thanks! 💚

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Looking great overall! My comments are very minor.

@deivid-rodriguez I'm wondering what to do with this - do you think it's ready for merge? I mean we're "only" at beta releases right now any way. I'd like to merge it because it touches/alleviates some of the problems of #820 and so if I also did something in #824 (which is blocking a beta2 release right now) it'd most likely be a waste of time + merge problems for either your or me. None of which seem appealing to me right now. So I'd rather merge it sooner than later if you think it's cool :)

image

lib/simplecov.rb Show resolved Hide resolved
lib/simplecov.rb Outdated Show resolved Hide resolved
spec/simplecov_spec.rb Outdated Show resolved Hide resolved
spec/simplecov_spec.rb Outdated Show resolved Hide resolved
spec/simplecov_spec.rb Outdated Show resolved Hide resolved
@deivid-rodriguez
Copy link
Collaborator Author

@PragTob I have no problem with this getting merged now, although it contains a bunch of commits which seem completely unrelated to the coverage merging (although I did add them because of issues when getting the unit specs to pass, so I guess there's some relation after all).

So, your choice, I don't mind extracting those commits to a separate PR, and I don't care about rebasing stuff and fixing merge conflicts. Just let me know.

Regarding your feedback, yeah, I just wanted to push bare passing specs but I was planning to refactor and improve them afterwards.

I'll get this ready for you later today hopefully. I'd also like to do some commit history cleanup since there's a lot of stuff in here that can be squashed together, but I can also skip doing that if you prefer the original verbose git history of this PR.

@PragTob
Copy link
Collaborator

PragTob commented Jan 16, 2020

@deivid-rodriguez Thanks 💚 All volunteers here so no worries, but if you managed to do it by this evening that'd be super great. I'll leave my work on #824 alone until it's done or tomorrow morning or so then.

I'd appreciate a bit of squashing (not strictly necessary from my side but some fewer seems like a nice idea) :) While I sympathize with extracting it to a separate PR I think it's fine to have in here - these things sometimes escalate and happen but imo it's small enough (and I've already reviewed it anyhow) to keep in here imo :)

Thanks heaps!

IMG_20180805_081900

@deivid-rodriguez
Copy link
Collaborator Author

I addressed your feedback. If you're good with the current version I can do a pass of squashing.

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

🎉

@PragTob
Copy link
Collaborator

PragTob commented Jan 17, 2020

@deivid-rodriguez I'm good with it, ruby 2.4.9 seems to have a legit failure though 😱

Anyhow, thanks a bunch for the work! 💚

@deivid-rodriguez
Copy link
Collaborator Author

It seems like a flaky... :(

@deivid-rodriguez
Copy link
Collaborator Author

I can reproduce locally using the same test seed, will have a look.

@deivid-rodriguez
Copy link
Collaborator Author

It should be ok now. I'll do the squashing.

@deivid-rodriguez
Copy link
Collaborator Author

I think I detected a potential bug while squashing, I'll have a closer look later.

@deivid-rodriguez
Copy link
Collaborator Author

deivid-rodriguez commented Jan 17, 2020

Ok, so I pushed a cleaner git history, which consists of the following:

  • 8977f97 and 8a62099 implement essentially the same feature as Add method to shutdown and collect results before at_exit  #731, so they essentially supersedes that PR. You can now call SimpleCov.run_exit_tasks! directly, and exit tasks will be avoided in that case. I added this feature because I needed it to get cucumber scenarios passing, since some of the magic was happening in the at_exit hook making it really difficult to test. I kept @macumber's attribution since I used his idea and part of the code.

  • 0234c60, 0c33f1a and 5061173 implement "full symbolization", which might or might not help with Fix crash when parsing previous version resultset.json  #820, since it removes the code path where the crash happens. I needed this because my unit tests for merging reports were getting confused because some reports had symbol keys and others string keys.

  • 3409893 as explained before removes the ":branches" section from reports if branch coverage is not enabled.

  • f02b0a4 and 8ff1295 fix some test suite state leaks causing order dependent failures.

  • 885ddd5 fixes a typo.

  • b64b148 improves our test app scenario setup so that it doesn't depend on scenarios setting up LOAD_PATHs.

  • b678cf3 implements the result collation feature.

@deivid-rodriguez
Copy link
Collaborator Author

That "potential bug" was a false alarm by the way 😅.

@deivid-rodriguez
Copy link
Collaborator Author

It's a flaky world! I'll have a look at the new failure :)

@PragTob
Copy link
Collaborator

PragTob commented Jan 17, 2020

Yay flakies! 💃 🙄

Good luck with those. I guess instead of waiting I might just rebase my branch against this one and work from there, might be the most efficient so close to the finish line.

Also btw you're probably better equipped than me to write the Changelog (doesn't need to be within this PR, can be separate)

Full symbolization helps with #820 but doesn't fully fix it (it helps for the case where the report is outdated) - fixing it will sadly be somewhat "dirty" or at least that's the only way I know how to (rescuing errors from the code that does the actual merging, print a warning, return empty value - while not great this helps us to not repeat this once we change the format again)

Cheers and a bunch of thanks!

deivid-rodriguez and others added 10 commits January 17, 2020 15:42
For example, if `SimpleCov.run_exit_tasks!` has been called explicitly,
we don't want to call it again.

This is a useful feature for testing the collation feature that I'll be
adding in follow up commits, but also has other use cases.

Co-authored-by: Dan Macumber <dan.macumber@gmail.com>
Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Dirty tests should clean up after themselves, not cleanup other dirty specs
leaks.

In this case, the specs were cleaning up dirty state before them, so
they could work, but leaking state after being running.
Branch coverage needs to be enabled for this test to properly run.
So that cucumber scenarios never depend on having to properly set the
$LOAD_PATH.
@deivid-rodriguez
Copy link
Collaborator Author

I fixed the flaky and wrote changelog entries!

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

🎉

@PragTob PragTob merged commit 50a1b46 into simplecov-ruby:master Jan 17, 2020
@deivid-rodriguez deivid-rodriguez deleted the allow-manual-merging branch January 17, 2020 15:14
@ticky
Copy link
Contributor

ticky commented Jan 17, 2020

Thanks so much for your work getting this over the line! Super excited for this to hit a release :)

@PragTob
Copy link
Collaborator

PragTob commented Jan 20, 2020

@ticky it's live now as 0.18.0.beta2 - if you could give it a try that'd be highly appreciated! :)

@ticky
Copy link
Contributor

ticky commented Jan 28, 2020

Working great for us! Loving it :)

@PragTob
Copy link
Collaborator

PragTob commented Jan 29, 2020

Happy to hear it!

WhatsApp Image 2019-06-26 at 08 42 20

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.

None yet

3 participants