go-mysql-server icon indicating copy to clipboard operation
go-mysql-server copied to clipboard

Testify getting included in binary builds.

Open joel-rieke opened this issue 3 years ago • 3 comments

While pulling in the project, I noticed I was getting somewhat larger builds. One thing I did notice is that testify was getting sucked into the builds (which should never happen). This can happen if you don't use the *_test.go convention for all your test files containing testify. I found maybe 5-6? I renamed them in my fork for now because I'm not sure if the way I renamed them would break any of your automated tests.

Simply renaming this files to _test.go equivalents removed testify from the build.

On another note, I wonder if other things could be getting sucked in as well given the thing with testify was happening.

joel-rieke avatar Aug 18 '22 00:08 joel-rieke

You mind sending over a PR with your renamed files?

timsehn avatar Aug 18 '22 00:08 timsehn

Let me check into a few things first. I have other changes that are a part of this branch. If they were accepted, it would be great because I could get rid of my fork.

joel-rieke avatar Aug 18 '22 14:08 joel-rieke

Let us know if you found any more clues. We'd love to get this fixed up and let you get rid of your fork so you can work on tip of main.

fulghum avatar Aug 23 '22 16:08 fulghum

I think the reason testify gets pulled in is because we export a set of acceptance tests for integrators (people building a database backend, like Dolt) can use to verify their integration. To my knowledge there is no other way to export test acceptance functionality as a library.

testify may get pulled in by a build process, but it should never actually make it into a binary because the go compiler should mark it as dead code (unreachable by the main method). Are you saying this isn't the case for you? Can you provide a repro?

zachmu avatar Oct 12 '22 20:10 zachmu

Yes, I was definitely seeing testify get sucked into the build. I used "strings" to see that testify was in the final binary. After renaming the test libraries as _test.go, they were correctly excluded. The final binary shrank significantly in size upon doing this.

joel-rieke avatar Oct 12 '22 21:10 joel-rieke

Thank you for bringing this to our attention.

We did this analysis for dolt, which depends on go-mysql-server, and found that there was only one test file that had this issue, in the server package. Removing that file got rid of the testify inclusion in the dolt binary (after some additional changes on the dolt side, where similar issues were happening).

Fixed in this PR:

https://github.com/dolthub/go-mysql-server/pull/1369

Please try that and let us know if you still see testify getting pulled into your build.

zachmu avatar Nov 03 '22 16:11 zachmu