Remove testing libraries from production environments #2406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the issue of testing libraries being included in production builds, which unnecessarily increases binary size.
Problem
The
github.com/stretchr/testifylibrary was being imported by non-test files, causing it to be included in production builds even though it's only needed for testing.Changes Made
1. Renamed test utility files to follow Go conventions
block/test_utils.go→block/test_utils_test.goexecution/evm/test_helpers.go→execution/evm/test_helpers_test.goFiles with the
_test.gosuffix are automatically excluded from production builds by the Go compiler.2. Added build tags to exclude mock files from production
//go:build testtag toda/internal/mocks/da.goThis ensures mock files are only included when building with the
testtag.Verification
Production builds no longer include testify:
Tests continue to work:
Impact
The mock files in the
test/directory are naturally excluded from production builds due to their location, while the renamed utility files and tagged mock files ensure complete separation of test dependencies from production code.Fixes #2350.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.