Follow-up to #19315.
testify is still linked into the shipped binary, because these files are compiled into the regular (non-test) build:
That pulls testify/assert, testify/mock, objx, go-spew and go-difflib into the binary, all of which are still listed in docs/LICENSE_OF_DEPENDENCIES.md, and their init() functions run on every start.
The runtime cost is nothing like testcontainers-go was (mock compiles one regexp, assert does a handful of reflect calls), so this is about layering rather than startup time.
Why these four are grouped
Every symbol each of these files exports is only referenced from inside its own package, so renaming each one to *_test.go should be sufficient with no restructuring. They can be done one plugin at a time.
The fifth leaker, plugins/common/psutil/mock_ps.go, cannot be fixed this way and is tracked separately.
Related
#19373 proposes a CI guard so this class fails the build instead of being found by accident.
Verify
go list -deps ./cmd/telegraf | grep stretchr/testify
Follow-up to #19315.
testifyis still linked into the shipped binary, because these files are compiled into the regular (non-test) build:plugins/outputs/cloud_pubsub/topic_stubbed.goplugins/inputs/intel_pmu/mocks.gotest(inputs.intel_pmu): Refactor test code to prevent testing leakage to production code #19398
plugins/inputs/intel_dlb/ras_reader_mock.goplugins/inputs/libvirt/libvirt_utils_mock.goThat pulls
testify/assert,testify/mock,objx,go-spewandgo-difflibinto the binary, all of which are still listed indocs/LICENSE_OF_DEPENDENCIES.md, and theirinit()functions run on every start.The runtime cost is nothing like
testcontainers-gowas (mockcompiles one regexp,assertdoes a handful of reflect calls), so this is about layering rather than startup time.Why these four are grouped
Every symbol each of these files exports is only referenced from inside its own package, so renaming each one to
*_test.goshould be sufficient with no restructuring. They can be done one plugin at a time.The fifth leaker,
plugins/common/psutil/mock_ps.go, cannot be fixed this way and is tracked separately.Related
#19373 proposes a CI guard so this class fails the build instead of being found by accident.
Verify
go list -deps ./cmd/telegraf | grep stretchr/testify