Summary
Direct unit tests of module_qualifies_as_rstest_companion_module, module_has_inner_harness_descriptor_pairs, and collect_rstest_companion_test_functions in src/hir/mod.rs are architecturally blocked: all three functions require a live rustc_lint::LateContext to operate. There is no stable, lightweight seam that can construct that context in isolation, so the qualification logic cannot currently be exercised by ordinary unit tests.
Problem
Without a testable seam:
- Edge-case behaviour (empty companions, descriptor-only modules, false-positive sibling modules, deeply nested module groups) can only be validated through full UI-level compilation fixtures, which are slow and opaque.
- Regressions in the qualification predicate may go undetected until a UI test fails, with no easy way to bisect the failure to a specific code path.
Proposed resolution
Introduce a trait or a thin, data-only projection type that abstracts over the parts of LateContext / hir::Item used by the three functions. This would allow:
- Unit tests to construct lightweight fakes representing various module shapes (empty, descriptor-only, fn+const pair, unrelated const, etc.) and assert the correct qualification decision.
- The production path to continue using the real
LateContext-backed implementation with zero overhead.
Context
Identified during review of PR #221, where the architectural constraint was first documented in src/hir/tests.rs. The companion-module detection work is tracked by issue #225.
Raised by @leynos.
Summary
Direct unit tests of
module_qualifies_as_rstest_companion_module,module_has_inner_harness_descriptor_pairs, andcollect_rstest_companion_test_functionsinsrc/hir/mod.rsare architecturally blocked: all three functions require a liverustc_lint::LateContextto operate. There is no stable, lightweight seam that can construct that context in isolation, so the qualification logic cannot currently be exercised by ordinary unit tests.Problem
Without a testable seam:
Proposed resolution
Introduce a trait or a thin, data-only projection type that abstracts over the parts of
LateContext/hir::Itemused by the three functions. This would allow:LateContext-backed implementation with zero overhead.Context
Identified during review of PR #221, where the architectural constraint was first documented in
src/hir/tests.rs. The companion-module detection work is tracked by issue #225.Raised by
@leynos.