Skip to content

Fix mutation testing gaps#18

Merged
CamonZ merged 37 commits intomasterfrom
fix-mutant-tests
Mar 29, 2026
Merged

Fix mutation testing gaps#18
CamonZ merged 37 commits intomasterfrom
fix-mutant-tests

Conversation

@CamonZ
Copy link
Copy Markdown
Owner

@CamonZ CamonZ commented Mar 28, 2026

Summary

Systematic mutation testing fix across the entire code_search codebase. Every file targeted by cargo mutants now reports 0 missed mutants.

What changed

37 commits fixing tests across 36 tickets from the mutation testing epic. The work covers:

Shared infrastructure (2 commits)

  • Shared output/formatting tests (output.rs, commands/mod.rs)
  • Dedup utility tests (dedup.rs)

DB layer (8 commits)

  • Core extractor (db.rs) — 35 mutants
  • SurrealDB backend (backend/surrealdb.rs) — 62 mutants
  • Query modules: calls.rs (14), trace.rs (19), import.rs (58), duplicates.rs (21)
  • Types: call.rs, trace.rs (22)
  • Query builders & test utils (query_builders.rs, test_utils.rs) — 41 mutants

CLI commands (27 commits)

  • All 26 commands now have mutation-killing tests
  • Common patterns: run() integration tests (Table/JSON/empty), field-level assertions, direction-sensitivity tests, boundary condition tests, output snapshot tests

By the numbers

Metric Count
Commits 37
Tickets closed 36
Total mutants tested ~700+
Missed mutants 0

Approach

  1. Fix shared output/formatting patterns first (affects all commands)
  2. Lock down DB foundation bottom-up (extractor → backend → queries → types)
  3. Fix CLI commands (mechanical once patterns established)
  4. Verify each file with targeted cargo mutants -f <file> before committing

Test plan

  • cargo test passes (all 650+ tests green)
  • cargo mutants -f <file> reports 0 MISSED for every file changed
  • No regressions in existing tests

CamonZ added 15 commits March 28, 2026 03:46
Add targeted tests for TableFormatter default trait methods (output.rs)
and Unknown command error handling (commands/mod.rs). Exclude one
equivalent mutant where Vec::new() -> vec![] is a no-op replacement.
Add execute and output test modules covering cohesion ratio arithmetic,
boolean filter logic, threshold boundary values, accumulator operations,
cross-dependency generation, and exact output string matching. Simplify
three equivalent expressions to eliminate untestable mutants.
Add 36 unit tests to setup/output.rs covering conditional branches (>),
negation guards (!), and arithmetic (+) in SetupResult::to_table().
Tests verify skills, agents, hooks, and git config sections with exact
string matching.
Add execute and output test modules covering threshold boundary values
(>= vs <), compound AND filter logic, and exact output string matching.
Remove weak placeholder test that only checked struct field assignment.
Replace 5 tautological assertions with real group count, hash value,
and member count checks. Add build_by_module accumulation test, run()
integration tests, and hash truncation boundary tests for output.
Replace shallow !is_empty() assertions with exact count and content
checks, fix module_filter to use exact match, add run() integration
tests for Table and JSON output formats.
Add CLI parsing, output formatting, and execute boundary tests. Cover
scoring formula arithmetic, threshold boundaries, and run() integration
with Table/JSON output formats.
Add execute and output test modules covering DFS cycle detection,
max_length boundary, path guard comparisons, and exact table output
formatting. Make find_all_cycles/deduplicate_cycles pub(crate) for
testability.
Add CLI parsing, execute, and output test modules covering threshold
filtering, module grouping deduplication (! negation guard), and exact
output string matching for all formatters.
Add CLI parsing, execute, and output test modules covering clause count
thresholds, module grouping deduplication (! negation guard), and exact
output string matching for all formatters.
Add CLI parsing, execute, and output test modules with 32 tests covering
type pattern matching, module filtering, arity exclusion, and exact
output string matching for all formatters.
Replace empty execute_tests.rs with 12 tests covering dependency
relationships, no-match case, regex/limit filtering, and run()
integration for Table/JSON output.
Replace empty execute_tests.rs with 13 tests covering function signature
lookup, arity filtering, module scoping, and run() integration for
Table/JSON output.
Add CLI parsing, execute, and output test modules with 31 tests covering
return type pattern matching, module filtering, and exact output string
matching for all formatters.
Rewrite test module with 60 tests covering parse_single_field (|| guard),
parse_type_fields, format_type_definition, group_by_module,
group_by_module_with_file, group_calls, and convert_to_module_groups.
@CamonZ CamonZ changed the title Fix mutation testing gaps across 5 commands Fix mutation testing gaps Mar 28, 2026
CamonZ added 14 commits March 28, 2026 14:47
Comprehensive mutation-killing tests for output.rs (14/14) and
commands/mod.rs (2/2). Adds tests for format_entry_details,
blank_after_summary/blank_before_module branches, ModuleCollectionResult
to_table path, and format(Table) dispatch. Strengthens error message
assertion for unknown commands.
Add MockValue/MockRow test infrastructure and 30 targeted tests for
extract_bool, extract_f64, extract_call_from_row_trait,
escape_string_for_quote, and escape_string_single. All 29 viable
mutants caught (6 unviable).
Add tests for Array Value trait impl (as_str/as_i64/as_f64/as_bool
return None, as_array returns elements) and into_rows with actual data.
All 50 viable mutants caught (12 unviable).
Add 14 tests targeting && vs || mutations in caller/callee matching,
>= vs < in row length check, position filter boundary conditions
(start_line=0, end_line=0, empty kind), and arity filtering.
All 13 viable mutants caught (1 unviable).
Extract dedup_calls as standalone pub(crate) function for direct unit
testing. Add tests for header column matching (== vs !=), clause vs
function start/end_line field assignments, and dedup depth comparison
with controlled input ordering to kill < vs ==/<=  mutants.
All 15 viable mutants caught (4 unviable).
Add tests for create_schema persistence, import_json_str data insertion,
clear_project_data table emptying, create_has_clause_relationships count,
and default_complexity value. All 58 mutants caught.
Add edge-case fixture data and 4 tests targeting && vs || mutations in
the empty-field filter and > vs >= in duplicate threshold check.
All 20 viable mutants caught (1 unviable).
Add tests for Call::format_incoming (same/different module) and
TraceResult::empty with non-default values. All 18 viable mutants
caught (4 unviable).
…l all 41 mutants

Add tests for build_with_regex truth table (supports_regex x use_regex),
create_temp_json_file content verification, load_output_fixture content
check, and insert_defines/insert_has_clause DB persistence.
All 24 viable mutants caught (17 unviable).
Add 16 tests for deduplicate_retain and sort_and_deduplicate covering
duplicate removal, order preservation, custom keys, and edge cases.
All 2 mutants caught.
Add tests for execute() field values, clear flag reflection, and run()
output for both Table and JSON formats. All 9 mutants caught.
Add 7 tests targeting depth-1 dedup conditional mutations (== vs !=,
&& vs ||) in build_trace_result. All 38 mutants caught.
Add run() integration tests for Table/JSON output, regex flag parsing,
regex match/no-match/invalid tests. All 8 mutants caught.
Add field assertions on PathResult metadata and run() integration test
for formatted output. All 8 mutants caught.
CamonZ added 8 commits March 28, 2026 19:19
Rewrite output tests with exact assertions for format_summary,
blank_before_module, blank_after_summary. Add run() integration tests
for Table format. All 14 viable mutants caught (1 unviable).
[8cd5f3c4] Fix calls_to command tests — kill all 7 mutants

Add direction-sensitivity tests exploiting asymmetric call counts
between From/To, plus run() integration tests for Table/JSON output.
All 4 viable mutants caught (10 unviable).
Add run() integration tests, field-level assertions on DependentCaller,
output snapshot tests for empty kind, no-slash file paths, and multiple
targets. All 14 viable mutants caught (5 unviable).
Add name filter inclusion/exclusion tests killing the delete-! mutant,
and args-only/return-type-only output snapshots killing the || vs &&
mutant. All 21 viable mutants caught (3 unviable).
Add run() integration tests for Table/JSON/empty output, field-level
assertions, and pattern/guard output snapshots. All 7 mutants caught.
Add boundary test for > vs >= when total is 0, plus run() integration
tests for Table/JSON/empty output. All 12 mutants caught.
Add direct unit test for sort comparator with synthetic data that
distinguishes == vs != in tiebreaker, truncate_module_name boundary
tests, and run() integration tests. All 24 viable mutants caught
(6 unviable).
Add run() integration tests for Table/JSON/empty output covering the
full execute+format pipeline. All 6 viable mutants caught (5 unviable).
@CamonZ CamonZ merged commit f710a1f into master Mar 29, 2026
1 check passed
@CamonZ CamonZ deleted the fix-mutant-tests branch March 29, 2026 01:51
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