Skip to content

test(check): probe --changed scope boundaries with named gate assertions#48

Open
0xjgv wants to merge 2 commits into
mainfrom
unit7-changed-scope-probes
Open

test(check): probe --changed scope boundaries with named gate assertions#48
0xjgv wants to merge 2 commits into
mainfrom
unit7-changed-scope-probes

Conversation

@0xjgv

@0xjgv 0xjgv commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add two e2e scenarios to tests/features/interlock_stages.feature that prove the --changed contract explicitly:
    1. Graph-wide gates are skipped with named messages: verifies test: skipped under --changed, deps: skipped under --changed, and attribution: skipped under --changed each appear individually (not just the generic fragment)
    2. File-level gates run: verifies [fix] and [typecheck] appear in output when a changed Python file is present
  • Extract _stage_combined() helper in tests/step_defs/test_interlock_stages.py to deduplicate the stdout + stderr combination shared by both output assertion steps

Test plan

  • uv run pytest -q tests/step_defs/test_interlock_stages.py -k "changed" → 8 passed (6 pre-existing + 2 new)
  • uv run interlocks check --changed → lint, format, typecheck all green

Add two targeted e2e scenarios that prove the --changed contract in full:
- each graph-wide gate (test, deps, attribution) is skipped with its
  explicit named message (not just the generic "skipped under --changed" fragment)
- file-level gates (fix, typecheck) DO run on the scoped file set

Extract _stage_combined() helper in the step defs to deduplicate the
stdout+stderr combination shared by both output assertion steps.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new BDD scenarios to verify the interlocks check --changed command and refactors test utilities by extracting a helper function for process output. Feedback includes recommendations to consolidate the new scenarios for better performance, expand assertions for file-level gates, and ensure the new helper function is used consistently throughout the test suite.

Comment thread tests/features/interlock_stages.feature Outdated
Comment on lines +74 to +90
Scenario: `interlocks check --changed` skips each graph-wide gate with a named reason
Given a minimal tmp project initialized as a git repo
And the tmp project has a changed Python file
When I run "interlocks check --changed=HEAD" in the tmp project
Then the stage exits 0
And the stage output contains "test: skipped under --changed"
And the stage output contains "deps: skipped under --changed"
And the stage output contains "attribution: skipped under --changed"

# req: stage-check
Scenario: `interlocks check --changed` runs file-level gates on changed Python files
Given a minimal tmp project initialized as a git repo
And the tmp project has a changed Python file
When I run "interlocks check --changed=HEAD" in the tmp project
Then the stage exits 0
And the stage output contains "[fix]"
And the stage output contains "[typecheck]"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These two new scenarios (and the existing one at line 64) perform identical setup and execution steps (interlocks check --changed=HEAD on a project with a changed file). Since these are E2E tests involving git initialization and subprocess execution, they are relatively expensive. Combining them into a single scenario with multiple assertions would improve test suite performance while maintaining the same level of coverage.

Comment on lines +89 to +90
And the stage output contains "[fix]"
And the stage output contains "[typecheck]"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To fully verify the contract for file-level gates under the --changed flag, consider adding assertions for [format] and [crap]. These tasks are also scoped to changed files in the check stage and should appear in the output alongside [fix] and [typecheck].

    And the stage output contains "[fix]"
    And the stage output contains "[format]"
    And the stage output contains "[typecheck]"
    And the stage output contains "[crap]"

Comment on lines +141 to +142
def _stage_combined(result: subprocess.CompletedProcess[str]) -> str:
return result.stdout + result.stderr

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The PR description states that _stage_combined() was extracted to deduplicate logic shared by both output assertion steps. However, it is currently only used in _stage_output_contains. If the intention was to standardize output handling, consider also using it in _stage_exits (lines 134-138), although the current separate view in that function is admittedly better for debugging.

…rtions

Merges two separate --changed scenarios that had identical setup into one,
reducing redundant E2E subprocess + git-init overhead. Adds [format] and [crap]
assertions to fully cover all four file-level gates under --changed scope.
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