[py] Scope py_test_suite shared library to support files only#17600
Open
AutomatedTester wants to merge 1 commit into
Open
[py] Scope py_test_suite shared library to support files only#17600AutomatedTester wants to merge 1 commit into
AutomatedTester wants to merge 1 commit into
Conversation
Previously py_test_suite() bundled all srcs (test files and support files) into one shared library, and every individual pytest_test depended on it. Changing any one test file dirtied the whole library and triggered a rebuild of all tests in the suite across all browser variants (~300+ targets for a single-file change). Now the shared library only contains non-test support files (helpers, utils, __init__.py, conftest). Each pytest_test still depends on that library for shared support code, but test files are no longer included in it. A change to alerts_tests.py now only rebuilds the alerts_tests-* targets instead of the full suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
py_test_suite()previously bundled allsrcs(both test files and support files) into one sharedpy_library, and every generatedpytest_testdepended on that libraryutils.py,webserver.py,__init__.py, etc.); test files are no longer bundled into itpytest_teststill depends on the support library for shared fixtures and helpers, so test execution is unchangedalerts_tests.pynow rebuilds only thealerts_tests-*targets (~6) instead of the full suite (~300+)How it works
The fix separates srcs into two buckets using the existing
_is_test()predicate:The shared
py_libraryis only created when support files exist, and eachpytest_testreceivesdepspointing to that support-only library (or the caller'sdepsdirectly if no support files exist).Test plan
bazel query 'labels(srcs, //py:test-chrome-test-lib)'returns only support files, no*_tests.pyfilesbazel query 'kind(py_test, //py:*)'still generates all 699 individual test targets