uber-go / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
2.13k stars 109 forks source link

added ignoring interfaces via -exclude_interfaces flag (#68) #72

Closed tulzke closed 1 year ago

tulzke commented 1 year ago

The problem is described in the issue. This is one of the solutions to this problem.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

r-hang commented 1 year ago

Thanks for contribution @Tulzke, i'm happy to discuss here or in the ticket but I think the the exclusion list as a mockgen flag parameter is the best approach as (1) command line flags are current mechanism by which mock options are configured and (2) users won't be required to modify their source code to take advantage of the feature.

tulzke commented 1 year ago

@r-hang , thanks for reply. Yes, I can do this via the flag parameter. What naming should I do for this? Maybe -exclude with comma separated interface names? Example: mockgen -exclude=Constraint,IgnoreMe -source=file.go -destination=file_mock.go

r-hang commented 1 year ago

@Tulzke how about exclude_interfaces in case there is something in the future that we'd want to exclude from generated code.

tulzke commented 1 year ago

@r-hang, sounds good. I have already committed this.

r-hang commented 1 year ago

@Tulzke the core logic looks could to me. However, could we add some tests for the newly added parseExcludeInterfaces function?

tulzke commented 1 year ago

@r-hang good point. I added a unit test for the function, and then changed the implementation to satisfy the test cases.