Skip to content

[py] Scope py_test_suite shared library to support files only#17600

Open
AutomatedTester wants to merge 1 commit into
trunkfrom
worktree-fix-py-test-suite-lib
Open

[py] Scope py_test_suite shared library to support files only#17600
AutomatedTester wants to merge 1 commit into
trunkfrom
worktree-fix-py-test-suite-lib

Conversation

@AutomatedTester
Copy link
Copy Markdown
Member

Summary

  • py_test_suite() previously bundled all srcs (both test files and support files) into one shared py_library, and every generated pytest_test depended on that library
  • Changing any single test file dirtied the whole library, causing all tests in the suite to be marked affected and rebuilt — roughly 300+ targets for a one-line change in one test file
  • Now the shared library only contains non-test support files (helpers, utils.py, webserver.py, __init__.py, etc.); test files are no longer bundled into it
  • Each pytest_test still depends on the support library for shared fixtures and helpers, so test execution is unchanged
  • A change to alerts_tests.py now rebuilds only the alerts_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:

support_srcs = [src for src in srcs if not _is_test(src)]

The shared py_library is only created when support files exist, and each pytest_test receives deps pointing to that support-only library (or the caller's deps directly if no support files exist).

Test plan

  • bazel query 'labels(srcs, //py:test-chrome-test-lib)' returns only support files, no *_tests.py files
  • bazel query 'kind(py_test, //py:*)' still generates all 699 individual test targets
  • Existing Python unit and browser tests pass

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.
@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations labels May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants