Skip to content

Commit b044c82

Browse files
committed
improve TESTS_ORACLE_PROMPT.md with semantic impact analysis
1 parent 74588fa commit b044c82

1 file changed

Lines changed: 45 additions & 10 deletions

File tree

TESTS_ORACLE_PROMPT.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,51 @@ RIGHT: "Smoke test X uses fixture Y, which depends on the changed fixture Z"
7878

7979
### For This Repository
8080

81-
This is a **test suite repository** — the changed files ARE often the tests themselves, or test infrastructure (fixtures, utilities, conftest files). Adapt analysis accordingly:
82-
83-
- If changed files are test files: recommend running those changed tests, plus any other tests that share fixtures, utilities, or base classes with them.
84-
- If changed files are test utilities/fixtures/conftest: recommend running all tests that depend on or import from the changed utilities.
85-
- If changed files are under `utilities/` or `libs/`: trace which tests import from these modules and recommend those tests.
81+
This is a **test suite repository** — the changed files ARE often the tests themselves, or test infrastructure (fixtures, utilities, conftest files). Adapt analysis accordingly.
82+
83+
### Semantic Impact Analysis (CRITICAL)
84+
85+
Do NOT recommend tests based solely on import relationships or file proximity. Analyze the **semantic impact** of each change:
86+
87+
**Changes that DO require test execution:**
88+
- Modified test logic, assertions, or parametrization
89+
- Modified fixture behavior (return values, setup/teardown, scope changes)
90+
- Modified utility functions that are called during test execution
91+
- Changed function signatures that tests depend on
92+
- Bug fixes in shared code paths
93+
94+
**Changes that do NOT require test execution:**
95+
- New opt-in features behind CLI flags (e.g., `--analyze-with-ai`) that are disabled by default
96+
- New imports in conftest.py that only activate under explicit opt-in conditions
97+
- Documentation files (`.md`, `README`)
98+
- Linter configuration (`.flake8`, `.ruff.toml`)
99+
- Dependency additions for opt-in features
100+
- Session lifecycle hooks (`pytest_sessionstart`, `pytest_sessionfinish`) that do not affect test collection, execution, or results under default settings
101+
- Coverage configuration changes
102+
103+
**For conftest.py changes specifically:**
104+
1. Check if the change affects test COLLECTION (markers, parametrization, item modification)
105+
2. Check if the change affects test EXECUTION (fixtures used by tests, hooks that modify test behavior)
106+
3. Check if the change is INERT under default settings (opt-in flags, conditional imports)
107+
4. Only recommend tests if the change affects collection or execution under default settings
86108

87109
### Dependency Tracing
88110

89-
1. Examine code changes in each modified file
90-
2. Identify affected code paths, functions, and classes
91-
3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes
92-
4. Trace test dependencies through imports, shared utilities, and fixture inheritance
93-
5. Detect new tests introduced in the PR
111+
When changes DO require test execution, trace dependencies precisely:
112+
113+
1. Examine code changes semantically — understand WHAT changed, not just WHERE
114+
2. Identify affected code paths and whether they execute during normal test runs
115+
3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers
116+
4. Trace ONLY active dependency paths — imports that are actually called during test execution
117+
5. Distinguish between direct dependencies (test calls changed function) and inert dependencies (import exists but code path is gated behind a flag)
118+
6. Detect new tests introduced in the PR
119+
120+
### Verification Before Recommending
121+
122+
Before recommending any test, answer these questions:
123+
1. Does this test actually CALL or DEPEND ON the changed code during a normal test run?
124+
2. Is the changed code path active by default, or gated behind an opt-in flag?
125+
3. Would the test behave DIFFERENTLY after this change under default settings?
126+
4. Can I trace a concrete execution path from the test to the changed code?
127+
128+
If the answer to questions 1, 3, or 4 is "no", do NOT recommend the test.

0 commit comments

Comments
 (0)