Skip to content

test(vex): cover apply() counter and effect branches#51

Merged
Metbcy merged 1 commit into
mainfrom
test/35a-apply-counter-coverage
May 18, 2026
Merged

test(vex): cover apply() counter and effect branches#51
Metbcy merged 1 commit into
mainfrom
test/35a-apply-counter-coverage

Conversation

@Metbcy
Copy link
Copy Markdown
Owner

@Metbcy Metbcy commented May 18, 2026

What

Adds a test module to src/vex/apply.rs (which had zero direct tests) exercising every increment site and effect branch in the VEX apply pipeline.

Why

Part of #35 (cargo-mutants audit on src/vex/**). The mutants run flagged 13 survivors clustered in apply.rs — including the "replace apply with ()" mutant, which means the entire function could be neutered and CI would stay green. That's a real regression risk: silent counter drift means wrong vex_suppressed_count in the summary, and a neutered apply() means --vex flags get ignored entirely.

What's covered

  • Empty-index fast path is a no-op (no annotations, no count bump)
  • Vulns branch: suppression drops the vuln, retain(!is_empty) removes empty purl keys, affected entries get annotated under cve:<purl>:<id>
  • Typosquats: suppression vs under_investigation annotation paths
  • Version jumps, maintainer age, license violations: each suppression path counted independently
  • vex_suppressed_count uses +=, not =: pre-existing counts from prior passes are preserved

Mutants killed (expected)

Site Mutants
replace apply with () 1
suppressed += 1 (+= -> -=/*=, replace += with =) ~12
enrichment.vex_suppressed_count += suppressed line 139 3

Re-running cargo-mutants on src/vex/apply.rs after this merges should drop the missed count substantially. A follow-up PR will mop up the remaining survivors in mod.rs, synthetic_id.rs, and detect_format.

Test counts

  • Before: 391 lib tests
  • After: 399 lib tests (+8)

All green locally with RUSTFLAGS="-D warnings" cargo build --all-targets --all-features + cargo clippy --all-targets --all-features -- -D warnings + cargo fmt --check.

Refs #35.

Adds a test module to src/vex/apply.rs exercising every increment site
and effect branch in the VEX apply pipeline:

- empty-index fast path is a no-op
- vulns branch: suppression drops, retain(!is_empty) removes empty keys,
  affected entries get annotated under cve:<purl>:<id>
- typosquats: suppression vs under_investigation annotation paths
- version_jumps, maintainer_age, license_violations: suppression counts
- vex_suppressed_count uses +=, not =, so prior counts are preserved

Closes a gap surfaced by cargo-mutants (#35): 13 survivors in apply.rs
covering the 6 'suppressed += 1' sites and the final accumulator. With
no tests calling vex::apply() directly, mutating any of the counters
(or replacing the whole function with ()) left CI green.
@github-actions
Copy link
Copy Markdown

Coverage report

Line coverage: 85.2% (9642 / 11311 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 Metbcy merged commit f51320e into main May 18, 2026
10 checks passed
@Metbcy Metbcy deleted the test/35a-apply-counter-coverage branch May 18, 2026 04:46
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