alunduil / alunduil/zfs-replicate

The structural test conventions fail a run rather than a review

Abierto
#680 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
24
Forks
6
Merge medio
3 h 11 min
PR fusionados (30 d)
49

Descripción

## User story

As a **contributor adding a test module**, I want **the conventions a machine can check to be checked**, so that **a missed one fails a run instead of waiting for a reviewer to spot it, and the prose stops carrying rules a tool could hold**.

## Current workaround

Three testing conventions are stated in prose and enforced by attention alone. Each has already drifted.

- **A test module mirrors its subject**, `_test` appended to every path segment. Nothing checks the mapping in either direction, so a module can gain code with no test module, and a test module can outlive the module it mirrors.
- **Every test package carries an `__init__.py`.** `cli_test/` and `task_test/` have gone without since before the convention; PR #621 adds them. Nothing stops the next directory landing without one, and the missing files are visible today as pytest collecting `cli_test/main_test.py` twice.
- **The module under test is imported as `sut`.** Half the suite does otherwise; #679 covers settling that.

The prose is the weakest place for a rule a tool could hold. It costs a reader on every visit, it cannot fail a pull request, and it drifts silently from what the suite does.

## Alternatives considered

- A `pre-commit` hook per check, matching how `vale`, `vulture`, and the FawltyDeps hooks already sit in `.pre-commit-config.yaml`.
- One script under `.github/scripts/`, called from a hook, the way `mutation-summary.sh` is called from the nightly job.
- A `ruff` custom rule, which covers the import alias but not the path mapping.
- Leaving the mirror check out: a module that genuinely warrants no test module would need an opt-out, and the list of those may be long enough to make the check noise.

## Acceptance criteria draft

- [ ] A check fails when a module under `zfs/` has no mirroring `_test` module, or a test module mirrors nothing, with an opt-out for the deliberate cases.
- [ ] A check fails when a directory under `zfs_test/` lacks `__init__.py`.
- [ ] Each check runs from `pre-commit` and in CI, and fails a pull request rather than reporting.
- [ ] Prose that only restated a now-checked rule is deleted rather than left beside the check.

## Additional context

- #679 settles the import alias, which has to land before a check for it can go on.
- #677 asks for exactly this: rules a linter could carry get filed for enforcement rather than restated.
- PR #621 fixes today's missing `__init__.py` files.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.