fix: preserve tested_by edges for Python test files under tests/ - #690
Open
sihaoqiaouzi wants to merge 1 commit into
Open
sihaoqiaouzi wants to merge 1 commit into
sihaoqiaouzi wants to merge 1 commit into
Conversation
`is_test_path` treats `tests/` as a test-source root only for Swift, Rust, and PHP — Python is absent from `_TEST_DIRECTORY_EXTENSIONS`. A Python project whose tests live under `tests/` without a `test_` prefix or `_test` suffix therefore has every production->test `tested_by` edge dropped during the merge: the pair is read as production-vs-production and discarded as semantically broken. Reproduced on a 30-file Python project with `tests/run_tests.py`, `tests/stage3_tests.py`, and `tests/stage4_e2e.py`. All three were classified as production files, so the merge reported 0 `tested_by` edges even though the file-analyzers emitted correct pairs. After adding ".py": - the files above (plus `tests/gen_data.py`) are recognized as tests; - the graph gains 17 `tested_by` edges and 12 `tested` tags (was 0 and 0); - the plugin's unittest suite passes: 93 tests (2 added here). The two new tests cover the directory rule for Python naming-convention false-negatives, and guard against a `tests` substring appearing elsewhere in a path. Related: Egonex-AI#586 and Egonex-AI#595 both report dropped `tested_by` edges, but for a different reason (path candidates that never reach the source file, or a suite outside any `tests/` root). This change only completes the extension list for the existing `tests/` root rule.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_test_path()treatstests/as a test-source root for Swift, Rust, and PHP — but Python is missing from_TEST_DIRECTORY_EXTENSIONS. Python files under atests/directory are only recognized when the basename carries atest_prefix or a_testsuffix.That leaves a common layout broken: a project whose suite lives in
tests/under names likerun_tests.pyorstage4_e2e.pygets every production-to-testtested_byedge dropped at merge time, because the pair is read as production-vs-production and discarded as semantically broken. The merge reports those edges as dropped, and the resulting graph shows zero test coverage for a repo that has a full test suite.Reproduction
A 30-file Python project —
tests/run_tests.py,tests/stage3_tests.py,tests/stage4_e2e.py, production underdata_agent/:tested_bypairs.merge-batch-graphs.pyclassified all three as production files and dropped every pair.tested_byedges.With this patch, on the same project:
is_test_pathon the 4 realtests/*.pyfilestested_byedges in graphtestedChange
Plus the matching docstring/comment update and two new tests:
test_python_tests_directory— Python naming-convention false-negatives (run_tests.py,stage3_tests.py,stage4_e2e.py,gen_data.py,helpers.py).test_python_non_test_paths— guards against atestssubstring appearing elsewhere in the path (data_agent/core/sqlite_utils.py,mypkg/testing/helpers.py,src/latest.py).The Swift/Rust/PHP cases added in #689 still pass.
Relation to the other
tested_byreportsBoth open issues below are about dropped
tested_byedges, but each has a different root cause. This patch is not a duplicate of either.tests/test_*.pylayout against a nestedsrc/<pkg>/<subpkg>/package produces 0 edges. There the path does match the convention, but the generated candidates never reach the real source file. This patch does not touch that code path.tests/root (scripts/verify-*.mjs) is never classified as a test. That case requires trusting the analyzers'testtag. This patch keeps the existing path-convention rule and only completes its extension list, so it stays correct — and complementary — if the tag-based approach lands later.Testing