Skip to content

Test/mutation testing remediation - #9

Closed
Squazz wants to merge 9 commits into
mainfrom
test/mutation-testing-remediation
Closed

Squazz wants to merge 9 commits into
mainfrom
test/mutation-testing-remediation

Conversation

@Squazz

@Squazz Squazz commented Oct 19, 2026

Copy link
Copy Markdown
Owner

No description provided.

Squazz and others added 9 commits October 19, 2026 07:14
Mechanical formatting only, so later diffs (and the PostToolUse format
hook) don't mix whitespace churn into behavior changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/helpers.py: isolated_env()/scrubbed_environ() strip SKIP_RATIO_CHECK,
  CLEANUP_*, TRANSMISSION_* and FETCH_TORRENTS_* (except the log dir), and
  make_temp_dir() removes its dir on cleanup.
- test_fetch_torrents applies isolated_env() module-wide, so an exported
  SKIP_RATIO_CHECK=true no longer fails 9 ratio-gate tests.
- The stagnation watch-file test pins ft.date instead of using date.today().
- The unsafe-name watch-file test asserts on disk instead of patching the
  process-wide os.remove (which log rotation also calls).
- Every mkdtemp/mkstemp in tests is now removed after the test.
- CI runs the suite a second time with a hostile environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds ShouldFetchTorrentBoundaryTests: ratio exactly 1.0 vs 0.999 (standard
and Devuan), only-newer / same-version-only records, highest older version
deciding, other-arch isolation, Devuan ignoring non-Devuan and same-release
entries, live-over-removed priority both ways, SKIP_RATIO_CHECK, unknown
distro and unparseable names. Every ShouldFetchTorrent* class now pins
SKIP_RATIO_CHECK=false in setUp.

Hand-applied mutants listed in the task are all killed; the one survivor
(dropping 'n in ratios or' in the removed-history loop) is equivalent,
since setdefault() already keeps the live ratio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers missing file, no markers, last-segment-wins, START without END,
END before the last START, name stripping, integer ratios not matching,
and duplicate names. get_previous_ratios is now fully covered by the
normal unittest run; the subprocess restart test stays as-is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bdecode silently accepted a byte string whose declared length ran past
the end of the data (b'4:ab' -> b'ab'), so a truncated .torrent decoded
into a wrong info dict and hash. Missing 'e'/':' terminators and
non-numeric integers/lengths leaked bare ValueErrors from bytes.index()
and int(); int() also accepted '1_0' and whitespace. All of these now
raise BencodeError naming the problem and its index. BencodeError still
subclasses ValueError, so existing callers are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full mutmut 2.5.1 re-run after tasks 10-13 left four killable
survivors in the touched functions:
- should_fetch_torrent: 'continue' -> 'break' and 'or' -> 'and' in the
  removed-history skip (a skipped legacy entry first, and no parse-error
  warning for entries without a ratio).
- bdecode: '>=' -> '>' on the end-of-data guard and the remaining-bytes
  arithmetic in the truncation message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The old loop kept an end_index that was reset on every START, which made
the 'end_index > start_index' check and the initial 'end_index = None'
redundant - mutmut reported both as surviving (equivalent) mutants.
Selecting 'after the last START, up to the last END after it' directly
removes them. A new test pins the existing 'last END wins' behavior
before the rewrite; mutmut now kills 28/28 mutants in the function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Squazz Squazz closed this Oct 19, 2026
@Squazz
Squazz deleted the test/mutation-testing-remediation branch October 19, 2026 16:54
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.

1 participant