test(typosquat): close 13 mutation-test gaps (#35)#66
Merged
Conversation
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.
Coverage reportLine 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; |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.rsout of 98 mutants (76 caught, 5 unviable).Categorized:
cache_filename, 504ecosystem_label) — accepted; documented in the audit logTests added
maven_best_match_includes_distance_equal_to_max_levenshtein>->>=maven_best_match_picks_closest_when_multiple_candidates_within_distancetrue/false/<(3 mutants)maven_best_match_score_formula_matches_one_minus_dist_over_len_plus_one+/-/*,-/+//,//%/*(6 mutants)suspicious_suffix_containment_requires_strict_delta_over_legit_len+->-default_cache_path_targets_typosquat_subdir_with_ecosystem_filenameNone,Some(Default::default())(2 mutants)Why label-string mutants are accepted
cache_filenamereturns a name that's joined into aPathBuf— no behavior pins the literal content as long as the path resolves with the right shape (the newdefault_cache_pathtest pins thetyposquat/<eco>.txtsuffix).ecosystem_labelis only used in a one-shoteprintln!log line; logging text is not contractual.Audit log entry in
docs/src/internals/mutation-testing.mdrecords both categories.Verification
cargo test --lib enrich::typosquat-> 50 passed (was 45)cargo clippy --all-targets -- -D warnings-> cleanFollow-up
License (14 survivors) and maintainer (54 survivors, needs HTTP mocking) still pending for round 2.