pre-commit registers only the commit's own tests
The pre-commit hook registers only the commit's own tests: the ones it adds, and the ones its workflow changes name. Part of #21946.
Before, the hook ran the registry writer over every unregistered test in the repository. If the base had a straggler, whichever pull request committed a test next carried it too. Every PR then added the same registry entries, and they conflicted with each other. The click-through lane hit this on #21272 with tests/test_cmux_next_base_autofix_finishes.py and tests/test_nightly_next_feed_rollback.py. This PR registers those two once on the base.
Change
validate_test_execution_registry.py --writetakes a repeatable--only PATH, andregister_derivable(root, only=...)registers just those paths. With no--only, it registers everything, as before.- The hook collects the tests it passes from
git diff --cached:- test files the commit adds;
tests/test_*.pypaths on added lines in workflow files.
Tests (committed failing first)
tests/test_install_git_hooks.py,test_pre_commit_registers_only_the_commits_own_tests. A repository whose base has an unregisteredtest_base.pycommitstest_mine.py.- Red: the hook registered both.
- Green: it registers only
test_mine.py.
tests/test_ci_test_execution_registry.py,test_write_only_registers_the_named_tests.- Red:
TypeError, sinceonlydidn't exist. - Green at the head.
- Red:
- All of
test_install_git_hookspasses. LaneRunnerTests.test_verify_local_jobs_option_keeps_recipe_tests_livefails both before and after this change in this sparse checkout.- The registry validator's "not run by any workflow" errors appear identically with the base registry, so they also predate this change.
The installed hook copies refresh when scripts/install-git-hooks.sh reruns, which post-merge does. A clone that still has the old validator copy ignores --only with an error, and the hook continues because registration is best effort.
Changelog
none
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Stops the pre-commit hook from writing the base's unregistered tests into every pull request. Part of #21946.
Before, the hook ran the registry writer over every unregistered test in the repository, so a stray test on the base got carried into whichever PR committed a test next, and identical registry entries conflicted across PRs. Now the hook registers only the tests the commit adds or that its workflow changes name. The base's two stragglers (tests/test_cmux_next_base_autofix_finishes.py, tests/test_nightly_next_feed_rollback.py) are registered once here.
Changes
validate_test_execution_registry.py --writeaccepts a repeatable--only PATH; without it, behavior is unchanged.- The hook collects candidates from
git diff --cached: addedtests/test_*.pyfiles and test paths on added lines in workflow files.