Skip to content

test(typosquat): close 13 mutation-test gaps (#35)#66

Merged
Metbcy merged 4 commits into
mainfrom
test/typosquat-mutation-survivors-35
Jun 2, 2026
Merged

test(typosquat): close 13 mutation-test gaps (#35)#66
Metbcy merged 4 commits into
mainfrom
test/typosquat-mutation-survivors-35

Conversation

@Metbcy
Copy link
Copy Markdown
Owner

@Metbcy Metbcy commented Jun 1, 2026

Round 2 of cargo-mutants follow-up for #35. Pattern matches #63 (baseline).

Survivor analysis

cargo-mutants round 2 found 17 survivors in src/enrich/typosquat.rs out of 98 mutants (76 caught, 5 unviable).

Categorized:

  • 13 logic / return-value mutants — closed by 5 new tests in this PR
  • 4 label-string mutants (lines 150 cache_filename, 504 ecosystem_label) — accepted; documented in the audit log

Tests added

test line(s) guarded mutants closed
maven_best_match_includes_distance_equal_to_max_levenshtein 371 > -> >=
maven_best_match_picks_closest_when_multiple_candidates_within_distance 375 guard true/false/< (3 mutants)
maven_best_match_score_formula_matches_one_minus_dist_over_len_plus_one 380, 381 +/-/*, -/+//, //%/* (6 mutants)
suspicious_suffix_containment_requires_strict_delta_over_legit_len 416 + -> -
default_cache_path_targets_typosquat_subdir_with_ecosystem_filename 471 None, Some(Default::default()) (2 mutants)

Why label-string mutants are accepted

cache_filename returns a name that's joined into a PathBuf — no behavior pins the literal content as long as the path resolves with the right shape (the new default_cache_path test pins the typosquat/<eco>.txt suffix). ecosystem_label is only used in a one-shot eprintln! log line; logging text is not contractual.

Audit log entry in docs/src/internals/mutation-testing.md records both categories.

Verification

  • cargo test --lib enrich::typosquat -> 50 passed (was 45)
  • cargo clippy --all-targets -- -D warnings -> clean

Follow-up

License (14 survivors) and maintainer (54 survivors, needs HTTP mocking) still pending for round 2.

Adds 5 tests covering 13 logic/return-value mutants in
src/enrich/typosquat.rs surfaced by cargo-mutants round 2:

- maven_best_match_includes_distance_equal_to_max_levenshtein:
  pins line 371 boundary (`>` vs `>=` at MAVEN_MAX_LEVENSHTEIN).
- maven_best_match_picks_closest_when_multiple_candidates_within_distance:
  pins line 375 match guard (true/false stubs + `>=`/`<` swap).
- maven_best_match_score_formula_matches_one_minus_dist_over_len_plus_one:
  pins lines 380-381 arithmetic (`+`/`-`/`*`, `/`/`%`).
- suspicious_suffix_containment_requires_strict_delta_over_legit_len:
  pins line 416 `+`/`-` mutant via strict boundary.
- default_cache_path_targets_typosquat_subdir_with_ecosystem_filename:
  pins line 471 None/Default::default stubs.

4 label-string mutants (lines 150 `cache_filename`, 504
`ecosystem_label`) accepted and documented in audit log — no
behavior depends on the literal string content.

cargo test --lib enrich::typosquat: 50 passed (was 45).
cargo clippy --all-targets -- -D warnings: clean.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Coverage report

Line coverage: 83.6% (9179 / 10976 lines)

Full lcov report available as workflow artifact coverage-lcov: download from this run.

v0.9.8 introduces this report; --fail-under-lines will be added once coverage is visible across 2–3 releases.

Metbcy and others added 3 commits June 1, 2026 21:35
…ndows

Windows uses backslash separators, so ends_with("typosquat/npm.txt")
fails on windows-latest CI. Compare file_name() and parent component
instead — separator-agnostic.
@Metbcy Metbcy merged commit 90052f2 into main Jun 2, 2026
10 checks passed
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