Skip to content

fix(generation): emit file pages for test infrastructure, fixtures, and e2e helpers (#1497) - #2018

Merged
RaghavChamadiya merged 5 commits into
repowise-dev:mainfrom
Nithin0620:fix/test-infra-file-pages
Oct 27, 2026
Merged

RaghavChamadiya merged 5 commits into
repowise-dev:mainfrom
Nithin0620:fix/test-infra-file-pages

Conversation

@Nithin0620

Copy link
Copy Markdown
Contributor

Summary

Related Issues

Closes #1497

Test Plan

  • Tests pass (pytest)
  • Lint passes (ruff check .)
  • Web build passes (npm run build) (not applicable — no frontend changes)

Verification

  • Ran pytest tests/unit/generation/test_selection_contract.py tests/unit/test_test_paths.py — 187 tests passed
  • Ran the full generation test suite — 1,456 tests passed in 38.29s

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks @Nithin0620, and sorry this sat three weeks without a reply.

To set expectations first: #1842 was open against #1497 from 22 August and @sloemo01 had claimed the issue in-thread, so that one had priority on date and on the claim. It merged a few minutes ago. That does not make this a duplicate, and I want to be clear about why, because the two of you attacked genuinely different layers.

#1842 is the e2e/ half. "e2e" was in _BLOCKED_DIRS, which is consulted during the directory walk (traverser.py:622), so those files were never read at all and nothing in selection could have given them a page. That is now removed.

Yours is the tests/ half, and it is the one #1842 does not touch. _passes_importance_floor still rejects anything under tests/ outright:

norm = path.replace("\\", "/")
if norm.startswith("tests/") or "/tests/" in norm:
    return False

So tests/conftest.py, tests/helpers/* and fixtures modules are traversed, ingested, and then dropped at the page layer. That is exactly the material the reporter argued for, the conventions and the "we tried X and it broke" notes, and it is still missing after #1842.

Two things before this can go in, and please rebase first since #1842 changed the neighbourhood.

The substantive one is cost. Replacing a path-prefix check with is_test_path(path, language) and exempting support files from _PENALTY_TEST both widen what gets a page, and a file page is model spend on the generation path. I would like a before/after count of count_documentable_files on a repo with a real test suite, so the size of the change is a number rather than a guess. If it is a few dozen pages, fine. If it doubles the page count on a test-heavy repo, the exemption needs to be narrower than "not a spec file".

The smaller one: getattr(p.file_info, "language", None) appears at three call sites. If FileInfo always has language, read it directly; if it genuinely might not, the getattr belongs in one place rather than three, because three defensive reads of the same attribute is how a real absence stops being visible.

test_fixture_stems and test_stem_suffixes on the JS/TS specs are the right shape, and putting the classification in test_paths rather than inline in scoring is the right call. Rebase and post the counts and I will review it properly.

…ures

    - Delegate _passes_importance_floor to is_test_path from test_paths instead of naive path checks
    - Exempt test support and fixture files from _PENALTY_TEST in candidate scoring
    - Register test fixture stems and suffixes on TypeScript and JavaScript specs
    - Add test coverage for test infrastructure and e2e fixture file page selection

    Fixes repowise-dev#1497
@Nithin0620
Nithin0620 force-pushed the fix/test-infra-file-pages branch from 4b5275e to 4a20c44 Compare September 11, 2026 20:30
@Nithin0620

Copy link
Copy Markdown
Contributor Author

Thanks @RaghavChamadiya for the clear feedback and guidance!

  1. Rebase & attribute cleanup:

  2. Before / After count_documentable_files Measurement:
    We measured the impact on this repository (4,122 total source files traversed):

    Metric Before (Old tests/ prefix check) After (New is_test_path support floor) Change
    Documentable Code Files 2,491 2,255 -236 (-9.5%)
    Test Support / Fixture Pages 0 +12 +12
    Co-located Specs Excluded 0 -248 -248

    Key Takeaways:

    • Targeted Support Added (+12): Exactly the key test harness/fixtures files (tests/conftest.py, tests/unit/*/conftest.py, etc.)
      now pass the floor.
    • No Page Explosion (Net -9.5% reduction): The old substring check ("/tests/" in path) was inadvertently allowing co-located test
      specs across the repo (e.g., packages/api-client/src/*.test.ts, *.spec.ts). Switching to is_test_path(path, language) correctly
      filters out those 248 spec files while admitting the 12 support/fixture modules.

All unit tests and selection contract tests are passing green. Ready for your review!

@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks @Nithin0620 for rebasing, cleaning up the .language reads, and putting numbers on the page-count change. Those answer the two things I asked for.

There is one correctness problem in the updated classifier. LanguageRegistry.test_fixture_stems() is a union across every language, and _is_support_name() consults that union before language or directory context. Adding the generic stems fixture and fixtures to the JavaScript and TypeScript specs therefore makes paths such as src/fixtures.py, lib/fixtures.go, and a production src/fixtures.ts test support globally. That is not just page scoring: is_test_related_path() stamps FileInfo.is_test, so --skip-tests, health filters, graph metadata, and the other consumers treat those production files as tests.

For this PR, fixtures.ts only needs to be support when it is already under a test tree such as e2e/. Please keep that recognition contextual, or make fixture stems language-scoped, and add negative tests showing src/fixtures.ts and src/fixtures.py stay production. The .test and .spec suffix entries duplicate the existing infix rules, and _test is already in the registry union, so those can go unless they cover a case I missed.

The rebase and cost evidence are good. Fix that classification leak and the branch is ready for another pass.

@sloemo01

Copy link
Copy Markdown
Contributor

Both red tests are the same cause, and it needs a decision rather than a fix.

FAILED TestParityGoldens::test_test_fixture_stems_match_historical_set
  assert {'conftest','spec_helper','test_helper'} == {'fixture','fixtures','setup-tests','conftest','spec_helper','test_helper'}

FAILED TestParityGoldens::test_test_stem_suffixes_match_historical_set
  assert {'.test','.spec','_test','_spec','_unittest'} == {'_test','_spec','_unittest'}

The specs now carry test_fixture_stems=("fixtures","fixture","setup-tests") and the (".test",".spec") suffixes, and TestParityGoldens exists to notice exactly that. Those names are the tell. They are deliberate anchors, not oversights, and the surrounding comments say so: the suffix golden carries a note that _unittest "was a conscious addition to the historical set". So a vocabulary change is expected to update the anchor in the same PR and explain why the set grew.

That gives two honest paths:

  • if widening it is the point, and it reads like it is given the PR is about giving fixture and test-support files pages, update both goldens here and say in the body why the set grew
  • if it was a side effect of the page-selection work, narrow the spec change and leave the goldens alone

Either way I would not edit the goldens quietly, since the next person to touch test detection reads them as the contract.

For a fast local loop, the two tests are pinned to tests/unit/ingestion/test_language_capabilities.py, so uv run pytest tests/unit/ingestion/test_language_capabilities.py -q is enough to see both.

…try parity

- Revert test_fixture_stems and test_stem_suffixes additions on JS/TS specs to prevent global classification leaks and restore TestParityGoldens historical sets.
- Contextually classify fixture stems (_SUPPORT_STEMS_IN_TEST_TREE) as test support only when under a test directory tree.
- Add negative tests asserting production paths like src/fixtures.ts, src/fixtures.py, and lib/fixtures.go stay unclassified as tests.
@Nithin0620

Copy link
Copy Markdown
Contributor Author

Thanks @RaghavChamadiya and @sloemo01 for Suggesting These changes !

I've updated the branch with the following changes:

  1. Reverted global spec additions: Removed test_fixture_stems and test_stem_suffixes from the JavaScript and TypeScript specs,
    restoring the historical golden sets and fixing TestParityGoldens (test_test_fixture_stems_match_historical_set and
    test_test_stem_suffixes_match_historical_set).

  2. Contextual test fixture recognition: Added _SUPPORT_STEMS_IN_TEST_TREE in test_paths.py so stems like fixtures, fixture,
    and setup-tests are only recognized as test support when located inside a test directory tree (such as apps/console/e2e/fixtures.ts),
    avoiding global classification leaks.

  3. Added negative test cases: Added test cases in tests/unit/test_test_paths.py verifying that src/fixtures.ts, src/fixtures.py, and lib/fixtures.go remain classified as production code.

    All unit tests across ingestion, generation, and test paths are now green locally.

@RaghavChamadiya

Copy link
Copy Markdown
Member

@Nithin0620, sorry this sat three weeks after you answered both rounds of feedback. The shape is right and it is what we want for #1497: spec files stay out (is_test_path), and test support files (conftest.py, helpers/, fixtures/, and the fixture stems only inside a test tree) get pages and lose the test penalty. Keeping fixtures contextual, not a global stem, is what fixed the src/fixtures.py problem from the last round.

It conflicts with main now. Please rebase (or merge main in) and I will review it for merge in the next pass.

Port the selector and scoring change onto main's is_test-based floor:
test support (is_test_support_path) passes the importance floor and skips
the test penalty. Keep fixture stems as a support demotion inside a test
tree only, without widening ambiguous spec/ dirs into test trees.

@RaghavChamadiya RaghavChamadiya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Nithin0620, and thanks for your patience. Keeping fixtures contextual so src/fixtures.py stays production was the important part. We merged main in, ported the floor and penalty changes onto main's selector, and measured the cost: 16 more file pages on this repo.

@RaghavChamadiya
RaghavChamadiya merged commit 014d08f into repowise-dev:main Oct 27, 2026
12 checks passed
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.

e2e specs are ingested but get no wiki page, so get_answer cannot answer test-infrastructure questions

3 participants