Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(test-paths): read a test-suite(s) directory as a test tree (#2987)
Raghav Chamadiyac43065493ab5
diff --git a/packages/core/src/repowise/core/test_paths.py b/packages/core/src/repowise/core/test_paths.pyindex 340d679fb..87e600f25 100644--- a/packages/core/src/repowise/core/test_paths.py+++ b/packages/core/src/repowise/core/test_paths.py@@ -68,6 +68,15 @@ _TEST_DIR_TOKENS: frozenset[str] = frozenset(# far more often than it names a suite._TEST_DIR_HEAD_WORDS: frozenset[str] = frozenset({"tests", "e2e"})+# Two-word heads that name a suite of tests: a Gradle module of shared test+# classes (``ktor-server-test-suites/jvm/src/``) or serde's ``test_suite/no_std/src/``.+# Only as a build module, so a ``src`` root must sit below it: a product feature+# folder (``src/features/test-suite/``) or a docs page set (``docs/test-suites/``)+# stays as it is. ``suite`` alone is not one (``office-suite/``).+_TEST_DIR_HEAD_PAIRS: frozenset[tuple[str, str]] = frozenset(+ {("test", "suite"), ("test", "suites")}+)+# The same head written in PascalCase or camelCase, one word with no separator:# ``UnitTests/``, ``UITests/``, ``FuzzTests/``, ``AdvancedPaste.UnitTests/``.# Plural only, for the reason above (``HitTest/`` is a UI feature), and matched@@ -303,6 +312,7 @@ def _has_test_layout(segments: list[str], original: list[str]) -> bool:rules = _conventions()return (_in_test_project(segments)+ or _in_test_suite_module(segments)or any(_contains_run(segments, needle) for needle in rules.dir_paths)or any(_has_wildcard_pair(segments, original, prefix_seg, camel_suffix)@@ -321,6 +331,13 @@ def _in_test_project(segments: list[str]) -> bool:)+def _in_test_suite_module(segments: list[str]) -> bool:+ return any(+ tuple(_words(seg)[-2:]) in _TEST_DIR_HEAD_PAIRS and "src" in segments[i + 1 :]+ for i, seg in enumerate(segments)+ )++def _contains_run(segments: list[str], needle: tuple[str, ...]) -> bool:span = len(needle)return any(tuple(segments[i : i + span]) == needle for i in range(len(segments) - span + 1))diff --git a/tests/unit/test_test_paths.py b/tests/unit/test_test_paths.pyindex 8174efce4..fa0367b22 100644--- a/tests/unit/test_test_paths.py+++ b/tests/unit/test_test_paths.py@@ -126,6 +126,17 @@ _CORPUS: tuple[tuple[str, str | None, str], ...] = (("apps/client-e2e/src/app.cy.ts", None, "test"),("apps/client-e2e/src/support/commands.ts", None, "support"),("mylib/unit.tests/run.py", None, "test"),+ # `test suite(s)` names a suite of tests when it is a build module with its+ # own `src` root: a Gradle module of shared test classes, serde's no_std check+ ("server/server-test-suites/jvm/src/io/x/suites/EngineStressSuite.kt", None, "test"),+ ("server/server-test-suites/common/src/io/x/suites/Utils.kt", None, "test"),+ ("server/x-test-suites/src/main/kotlin/io/x/ContentSuite.kt", None, "test"),+ ("test_suite/no_std/src/main.rs", None, "test"),+ # ...and not as a product feature folder or a docs page set+ ("src/api/test-suites/route.ts", None, ""),+ ("apps/web/src/features/test-suite/List.tsx", None, ""),+ ("docs/test-suites/overview.md", None, ""),+ ("conformance/test-suite/run.py", None, ""),# ...so a word that merely contains a test token, or a compound that is# *about* testing, is not a test tree("src/latest-release/api.py", None, ""),@@ -133,6 +144,9 @@ _CORPUS: tuple[tuple[str, str | None, str], ...] = (("docs/test-api/class-test.md", None, ""),("docs/test-tools/index.md", None, ""),("src/generators/e2e-project/index.ts", None, ""),+ ("apps/office-suite/src/main.ts", None, ""),+ ("packages/test-suite-runner/index.js", None, ""),+ ("server/server-test-host/src/io/x/TestEngine.kt", None, ""),# singular `test` heads a compound naming one thing - a generator, an# executor, a package, an example project - in either spelling("src/generators/component-test/index.ts", None, ""),