-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Internal registry for disambiguated imports, vars #141
Conversation
ffa3a9f
to
d3cc5b4
Compare
a06fa7f
to
fc112c8
Compare
@sudo-suhas We have the situation described in #94. I did a test with this PR and I can confirm, that it worked. Regarding the breaking change, could you provide an example, that illustrates when and how the breaking change could potentially affect existing (test) code. |
@breml an example of the breaking change is present in one of the 'golden' files generated via tests - https://github.com/matryer/moq/pull/141/files#diff-f8cb62335f3c482f132a362ff53cecc339a89fabfdc2ed25539b283308509678R36-R39 |
fc112c8
to
79efcfe
Compare
@matryer this PR fixes the issue reported in #94. There are other PRs which also attempt to do the same. The difference would be that this introduces some abstraction and splits the Mocker into more manageable pieces rather than trying to fit the disambiguation logic for imports and variables into the existing type. |
@matryer I spent some time to have a more in depth look at this PR. TLDR: The result seems good, at least it worked for me. The PR as a whole is really difficult to review. I have the following thoughts about this PR:
With all that said, to me the question is, are we willing to merge this PR to fix the before mentioned issues while taking the risk, that other things might be broken, due to the difficulty to properly review this PR and due to the missing tests/coverage for certain areas of the code. |
79efcfe
to
6dbb568
Compare
@breml Thank you for taking the time to review the changes. I appreciate it very much. I do have some clarifications though.
The golden file tests were added some time back. While I was adding new tests, I moved most of the existing golden file tests into a single table-driven one. I have added a commit which refactors the existing tests in a separate commit.
I agree that the PR does a lot of changes. That's partly because I was (and am) not sure how to split some of the changes. For example, I am not sure how I can split the
With the introduction of
The generated names for method parameters is used only if there wasn't one defined in the interface definition (or was
This is mostly because I am not sure how I can test these. Consider All that said, I am still open to listing the specific steps we could take to make the PR easier to review and also improve the confidence for merging in the changes. But I would need your help to figure out what those steps need to be. |
6dbb568
to
3dee993
Compare
- Move functionality in the moq package partially into internal/{registry,template}. - Leverage registry to assign unique package and variable/method parameter names. Use import aliases if present in interface source package. BREAKING CHANGE: When the interface definition does not mention the parameter names, the field names in call info anonymous struct will be different. The new field names are generated using the type info (string -> s, int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int -> stringToInt etc.). For example, for a string parameter previously if the field name was 'In1', the new field could be 'S' or 'S1' (depends on number of string method parameters).
3dee993
to
3692ecd
Compare
@sudo-suhas Thanks for your reply. As mentioned already in my first review comment, I think this PR brings a lot of improvement. I consider myself a regular user of I spent again some time on this PR and I have the following additional input for you: Generate an instance of
|
Maybe I came across as defensive 🙈 but I was not offended in the least. I will find some time to incorporate the helpful input you have provided. |
$ is set to the data argument passed to Execute, that is, to the starting value of dot. Variables were declared to be able to refer to the parent context.
@sudo-suhas Would you be up for a quick 15 minute screenshare some time to go through this? It looks like you've done a lot of work here, and I want to make sure I understand the new design, and your thinking behind it. |
Sure @matryer, can do. Should we chalk out the time and tool via Twitter DMs? |
@matryer, @sudo-suhas Did it workout with your direct chat about this PR? What are the conclusions? |
No, not yet. We will try to sort it out soon. |
@matryer I have created a deck which
Please check it out - https://docs.google.com/presentation/d/1-HVOygCVpQQ_8ikE2_OYzlvuH1NYI3wT02PWn0Onpcc/edit?usp=sharing. |
This is great work. And the overview by @sudo-suhas is outstanding. Thank you. |
Thank you @matryer for your kind words 🙏🏼 With regards to the tagged release |
@sudo-suhas ahh yeah - that's a good point. Do you think it's worth removing the release and retagging? Or has that ship sailed now? Technically, moq hasn't yet reached v1, but the last thing we want is to break things for those using this tool. |
The correct way to handle it would be to release |
What's the advantage of bumping the minor release? Is this respected by tools, or just a better signal to moq users? |
|
To the best of my understanding, for v0 semantic versioning, bumping the minor version indicates a breaking change while incrementing the patch version is expected to add new backwards-compatible features or bug fixes. |
Oh right, in modules you mean? Yeah ok, it's worth doing then. I'm away from my computer for a bit, do you have the right permissions to do a release? |
Have created both releases as discussed. Conclusion: Use moq |
Thanks Suhas. 🎉
…On Tue, 2 Feb 2021 at 07:30, Suhas Karanth ***@***.***> wrote:
Have created both releases as discussed.
Conclusion: Use moq v0.2.0
<https://github.com/matryer/moq/releases/tag/v0.2.0> to get the changes
made in this PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#141 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAY2G3DMYUTDVC5DZXK3VTS46SZ7ANCNFSM4UIOVAMQ>
.
|
Thanks @sudo-suhas and @matryer for the great work, this is very much appreciated. |
Closes #68, #94
Replaces and closes #63, #120, #121, #127
TODO:
@matryer this is a significant refactor and would be very good to get a review.
edit: Presentation deck - https://docs.google.com/presentation/d/1-HVOygCVpQQ_8ikE2_OYzlvuH1NYI3wT02PWn0Onpcc/edit?usp=sharing, which