Closed s4s7 closed 9 months ago
@s4s7 Thanks for the investigation with such details. Fortunately, the change on gomock hasn't been released yet.
Based on the commit you shew, seemingly we should use --write_command_comment=false
on mockgen internally (ref1, ref2).
Are you willing to help contribute again? :)
Also, the difficulty here is the version difference. If users' installed mockgen is the older version, mockgen
wouldn't accept write_command_comment
flag and error out.
Once the change on gomock side is released, we also have to cut the release, calling out this breaking change with it - the required action from users would be updating mockgen
version on their local machine/CI.
I want to contribute again, thank you!
Sorry, I may have mislead you a bit.
It seems that the gomockhandler -config=./gomockhandler.json check
is already not working correctly in go.uber.org/mock/mockgen@v0.4.0
.
I think we need to include a process that replaces // mockgen -destination=usecases/mock/tmp_xxx.go
with // mockgen -destination=usecases/mock/xxx.go
within the commented-out section to perfectly matche tmpFile(/mock/tmp_xxx.go
) with the file(/mock/xxx.go
) generated by mockgen.
Do we miss something else? since https://github.com/uber-go/mock/commit/2c718f249a424ac6ce6e2afa28c3c17f95c51241 is not included in mockgenv0.4.0
.
Ah, now I got it: the command generated in mock files is implemented in past release, https://github.com/uber-go/mock/issues/104 proposed the way to disable it, and it comes to write_command_comment
option now.
Yeah, so we have to think the way of avoiding this issue without write_command_comment
.
I think we need to include a process that replaces
Yup, looks good. Let's give it a try.
Published https://github.com/sanposhiho/gomockhandler/tree/v1.5.0, try out it!
Version
Actual behavior
Despite the mock being up to date, the
gomockhandler -config=./gomockhandler.json check
command reports a different checksum value, leading to the determination that it is not the latest version.[ERROR] mock is not up to date. destination: usecases/mock/xxx.go
Expected behavior
gomockhandler -config=./gomockhandler.json check
command works correctly.Why this issue occurred
https://github.com/uber-go/mock/commit/2c718f249a424ac6ce6e2afa28c3c17f95c51241 was merged and is affecting gomockhandler, causing the check command to not work correctly.
Detail
The checksum values differ because the file paths for the destination specified in the comments within code A and code B are different.
code A : generated code by go.uber.org/mock/mockgen
code B : tmp file code to calculate checksum in this line