Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Select tests of a definition whose decorators changed (0.261.531) - #2023

Merged
Paul Lizer (paullizer) merged 2 commits into
microsoft:Developmentfrom
paullizer:claude/select-tests-decorator-changes
Dec 2, 2026
Merged

Paul Lizer (paullizer) merged 2 commits into
microsoft:Developmentfrom
paullizer:claude/select-tests-decorator-changes

Conversation

@paullizer

Copy link
Copy Markdown
Collaborator

This sits on top of #2019 (claude/select-tests-helper-paths, 0.261.530), which is still open and rewrites the same file. Until #2019 merges, this pull request's diff also shows its commit; the change here is the last commit only. Merge #2019 first.

What was wrong

scripts/select_tests.py chooses the functional test files CI runs for a pull request into Development. It did not see a changed decorator on a top-level function or class as a change to that definition.

top_level_sources cut each definition's source from node.lineno, which for a decorated definition is the def/class line. The decorator lines were in no definition's source:

old = '@bp.route("/api/a")\n@login_required\ndef a():\n    return 1\n\ndef b():\n    return 2\n'
new = '@bp.route("/api/a")\ndef a():\n    return 1\n\ndef b():\n    return 3\n'
select.changed_names(old, new)   # {'b'} before, {'a', 'b'} now

So removing @login_required from a() while editing b() ran the tests of b() only. With the decorator as the only change in the module, the selector fell back to the whole module, which was safe.

Change

  • first_line(node) gives the line of a statement's first decorator. top_level_sources starts each definition there.
  • names_using and closed_names read the same sources, so a definition now counts as using the names in its decorators. A decorator runs at import and wraps the function, so a change to swagger_route reaches the top-level handlers that carry it.
  • helper_code cuts test helper definitions the same way and now starts at the first decorator too. Its name sets already included decorator names (ast.walk visits decorator_list); only its text stopped at the def line. That text is searched for application module references and route URLs, which a decorator can hold (@pytest.mark.parametrize("module", ["functions_documents"])), so the text and the names now cover the same lines.
  • A decorator-only change now selects the tests of the decorated definition instead of every test of the module.

Selection sizes

A change to scripts/select_tests.py makes CI run every test file, so these were measured locally with select.select(changed, known, old_source), one change at a time, old selector against new, on 2,045 test files:

Change Before After
Version bump in config.py alone 402 402
Body of get_auth_security in swagger_wrapper.py 413 447
Signature of swagger_route in swagger_wrapper.py 419 453
Body of login_required in functions_authentication.py 672 672

Every file selected before is still selected. The version bump and login_required select identical sets before and after.

The growth is small because most route handlers were never affected: 1,031 are defined inside a register_route_...(app) function, where their decorators are already inside that function's lines. 107 handlers sit at the top level of a blueprint module; those are the ones that now count as using swagger_route and get_auth_security.

(The version bump baseline was reported as 401 when #2019 was written; it measures 402 on this branch with both the old and the new selector.)

Tests

  • test_selector_sees_a_changed_decorator_as_a_change_to_its_definition in functional_tests/test_functional_suite_ci_runner.py, with two modules and three tests added to TINY_REPOSITORY: the case above, a decorator removed alone, a decorated class, a decorator removed together with an edit elsewhere, a change to the decorator's own code, and the helper text of a fixture.
  • functional_tests/test_functional_suite_ci_runner.py: 16 passed locally.

Documents

  • docs/explanation/fixes/FUNCTIONAL_TEST_SELECTION_DECORATOR_CHANGES_FIX.md (new)
  • docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md: rule added, the decorator line under "Limits" removed
  • Release notes entry for 0.261.531, pages rebuilt

🤖 Generated with Claude Code

…and same-module uses (0.261.530)

The pull request for 0.261.524 changed the orchestration planner's prompt and
discover_result_aliases, and passed CI without running six test files it broke.
select_tests.py did not select them, for three reasons:

- The five golden tests call planner.plan_request() on a module from
  import_module. A changed name counted only when no dot stood before it.
- The alias test reaches functions_orchestration_services through
  HarnessEnvironment in test_support and never names the module. Only a test's
  own text was read.
- A changed name was not followed into the definitions of its own module that
  use it, so a prompt-only edit selected 3 files and none of the goldens.

The selector now follows all three, and the same two forms between application
modules (import x as y; from x import name as other). Helper code is followed
by definition, and a name counts there only when Python resolves it, so a
version bump does not select the files that only check a version floor.

Every file selected before is still selected. Over the last 24 pull requests
the median selection goes from 300 to 454 files and the mean from 416 to 766.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
select_tests.py cut each top-level definition's source from the def/class
line, so decorator lines belonged to no definition. Removing a decorator
from one function while editing another in the same module selected only
the tests of the other.

A definition's source now starts at its first decorator, in
top_level_sources and in helper_code. A changed decorator changes the
definition, and a definition uses the names in its decorators.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@paullizer
Paul Lizer (paullizer) merged commit 99fb3e2 into microsoft:Development Dec 2, 2026
24 of 25 checks passed
Paul Lizer (paullizer) added a commit to paullizer/simplechat that referenced this pull request Dec 2, 2026
…lies is now 0.261.532

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Lizer (paullizer) added a commit to paullizer/simplechat that referenced this pull request Dec 2, 2026
…61.532); autoscaling defaults are now 0.261.533

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Lizer (paullizer) added a commit that referenced this pull request Dec 2, 2026
…1.536

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant