alunduil / alunduil/zfs-replicate

Tests pin the argv and error path in snapshot.list

未關閉
#668 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Python
星號
24
分支
6
平均合併
3 小時 11 分鐘
30 天內合併 PR
49

描述

## User story

As a **maintainer of zfs-replicate's test suite**, I want **tests that fail when `snapshot.list` builds the wrong `zfs list` invocation or mishandles a failed run**, so that **the module's 94% line coverage reflects assertions that actually constrain it**.

## Why

The mutation baseline from #485 leaves 50 survivors in `zfs/replicate/snapshot/list.py`, the largest concentration in the tree. Two clusters explain nearly all of them.

`_list` assembles the option list and nothing asserts on the result, so every literal in it can be rewritten and the suite still passes:

```
- options = ["-H", "-t", "snapshot", "-p", "-o", "name,creation", "-r"]
+ options = ["-H", "-t", "snapshot", "-p", "-o", "NAME,CREATION", "-r"]
```

`list` raises `ZFSReplicateError` on a non-zero return, and its three arguments can each be replaced with `None` or dropped without failing a test:

```
- raise ZFSReplicateError(f"error encountered while listing snapshots of '{filesystem.name}': {error!r}", filesystem, error)
+ raise ZFSReplicateError(f"error encountered while listing snapshots of '{filesystem.name}': {error!r}", filesystem)
```

`docs/reference/testing.md` already says command builders assert on `Command.argv` and `Command.render()` directly. `_list` is a command builder without that test.

## Acceptance criteria

- [ ] A test asserts the full argv `_list` produces, for both the recursive and non-recursive case.
- [ ] A test asserts the error `list` raises on a non-zero return, covering the message, the filesystem, and the cleaned stderr.
- [ ] `poetry run mutmut run --max-children 1 'zfs.replicate.snapshot.list.*'` reports no survivor that a test could have killed. Anything left is noted as an equivalent mutant.

## Out of scope

- The other modules in the #485 baseline; each has its own issue.
- Raising the mutation score anywhere a test would only be asserting on a log line.

## Notes

- Reproduce with `poetry install --with mutation` then `poetry run mutmut run --max-children 1`, and read one survivor with `poetry run mutmut show `. Serial matters: the parallel runner mis-attributes verdicts on this suite.
- Follow-up to #485.

貢獻指南

開啟貢獻指南

研究方向

Start with zfs/replicate/snapshot/list.py, then read docs/reference/testing.md for the command-builder testing convention. Run the focused tests and the serial mutmut command from the issue; done means both recursive cases assert the full argv and the failed listing asserts the error message, filesystem, and cleaned stderr, with no killable survivors.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli, testing
Issue 類型
重構
難度
3/5
預估耗時
1-2 天
活躍度
活躍
描述清晰度
描述清楚
新手友好度
75/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。