Skip to content

[#674-5/5] Reorganize tests/ to mirror src/ (or document deliberate flat layout) #679

Description

@kcenon

What

Reorganize the 57 currently-flat tests/ files to mirror src/{alert,collectors,context,core,modules,platform,plugins,utils}/, OR document a deliberate flat-layout exception in tests/README.md with explicit rationale. Pick whichever is right for this codebase — the EPIC explicitly allows either outcome.

Why

A flat 57-file tests/ directory makes test-to-source navigation harder than it needs to be. With src/ standardised across nine feature directories (after sub-issues #1-#4), mirroring is the lowest-friction layout: everyone knows that tests/<feature>/test_<thing>.cpp covers src/<feature>/<thing>.cpp.

Sometimes a flat layout is the right answer (e.g., if the tests are predominantly cross-feature integration scenarios that don't belong to any single feature). If so, document the rationale so future contributors don't re-debate this. The EPIC AC explicitly accepts either outcome with documentation.

Where

How

Technical Approach

Option A: Mirror src/ (preferred when most tests are unit tests for a single feature)

  1. Categorise each of the 57 files: which feature does it primarily test? (Inspect #includes and the test names.)
  2. Create tests/{alert,collectors,context,core,modules,platform,plugins,utils}/ as needed.
  3. git mv each test into the matching feature directory.
  4. For tests that cover multiple features, place them under a clearly-named subdirectory (e.g., tests/integration/) and decide whether they should live under integration_tests/ instead.
  5. Update test registration in CMake (which after feat: Phase 4 - Reliability & Safety Implementation #4 is cmake/test.cmake).

Option B: Document the flat layout

If the categorisation pass shows that flatness is genuinely intentional (e.g., > 50% of tests are cross-feature), add tests/README.md explaining:

  • Why flat is the right choice for this directory
  • How tests are named (so navigation works without subdirectories)
  • When a test should be split out (the criteria for moving into integration_tests/)

Decision Rule

Run the categorisation first (it's cheap). If 70%+ of the 57 files have a clear feature-owner, go with Option A. Otherwise, go with Option B.

Dependencies

  • Blocked by: src/impl consolidation sub-issue (so the feature dirs are stable to mirror)
  • Soft dependency: CMake decomposition sub-issue (cleaner test registration in cmake/test.cmake is easier to update than scrolling through the monolith — but not a hard block; this could land before feat: Phase 4 - Reliability & Safety Implementation #4 if needed)

Acceptance Criteria

  • Either: every test file under tests/<feature>/ matching src/<feature>/, OR tests/README.md documents the flat layout with clear rationale
  • CMake test registration updated to reflect the chosen layout
  • All ctest cases still discovered and passing
  • Build green
  • PR merged with every CI check pass/neutral

Estimated Size

S–M. Pure file movement (Option A) or documentation (Option B). The categorisation pass is the bulk of the work in either case.

Part of #674

Metadata

Metadata

Assignees

Labels

priority/highHigh priority - Critical for productionsize/MMedium - 1-3 days of worktype/refactorCode refactoring without functional changestype/testTest additions or improvements

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions