Skip to content

Test-suite structural gaps: 53 integration tests compile away on Windows, the rewrite table and the shared runner have zero tests, and savings tests measure with a different metric than the tool reports #3422

Open

Description

@HetCreep

Having filed a number of defects here, I went back and asked the more useful question: why did a green 2,520-test suite not catch them? The answer is structural rather than sloppy, and I think it is more actionable than any individual bug.

Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). Counts and the test run were produced on this machine; items marked SOURCE are read from code.

1. Six integration test files compile away on Windows — 53 tests

Every one of these starts with #![cfg(unix)]:

file tests
tests/search_faithful_test.rs 15
tests/search_compress_test.rs 14
tests/grep_faithful_format_test.rs 11
tests/grep_context_test.rs 6
tests/search_error_test.rs 5
tests/pipeline_stdin_test.rs 2

On Windows cargo test prints running 0 tests / test result: ok. six times — a green result for zero executed tests. .github/workflows/ci.yml:60 runs the matrix [ubuntu-latest, windows-latest, macos-latest] with a bare cargo test --all, and release.yml ships a Windows binary. So the Windows leg of CI proves nothing about grep, search, or the stdin pipeline — the areas those files cover.

Whether the gating is deliberate (POSIX-only assumptions in the fixtures) or accidental, the effect is that the Windows job's green tick is not evidence for those features.

2. The two files that decide everything have no tests

src/discover/rules.rs   1009 lines   0 tests
src/core/runner.rs       286 lines   0 tests

rules.rs holds the RULES table that decides which commands get rewritten and to what — the source of the yadm→git, gradle→gradlew, find -delete and biome check issues I filed. runner.rs is the shared exec → filter → guard → tee → track → exit-code skeleton every *_cmd.rs funnels through.

Also zero tests: analytics/gain.rs (762 lines), discover/mod.rs (297), cmds/system/summary.rs (301), cmds/system/deps.rs (277).

This is the structural answer to the question in the title: the leaves are well tested, the trunk is not. Most *_cmd.rs files have thorough tests of their pure filter functions, and those functions are usually correct — the defects live in how they are wired together.

3. Savings tests measure with a different metric than the tool reports

Tests assert with core/utils.rs:300 count_tokens = split_whitespace().count() (words). Production rtk gain and the never_worse guard (core/guard.rs:8) use estimate_tokens = ceil(len/4) (bytes).

On the project's own fixture tests/fixtures/mvn_test_pass_slice_raw.txt, the two disagree across the 60% floor: 35.6% by words, 62.4% by bytes. So a test asserting savings >= 60.0 is asserting a number the tool never reports, in either direction.

Related: cmds/system/pipe_cmd.rs:560,581 assert savings >= 40.0 with the comment // TODO: grep pipe filter below 60% target. .claude/rules/cli-testing.md calls ≥60% "the release blocker". The two filters known to miss the floor had their own gate lowered to 40, so the gap can neither be detected as fixed nor as regressed.

4. A few tests that cannot fail

  • cmds/system/search.rs:1334 test_grep_overflow_uses_uncapped_total — the body is let total = per_file + 42; let overflow = total - per_file; assert_eq!(overflow, 42). per_file cancels; it calls no production function. Its comment says it "documents that the search filter avoids the diff_cmd bug", but the filter's overflow path is never touched.
  • jvm/mvn_cmd.rs:1938 print_savings_summary — a #[test] with zero assertions (two println!s) and #[ignore]d, so it can neither fail nor be seen.
  • discover/registry.rs:4078 test_all_patterns_are_valid_regex re-compiles patterns that registry.rs:52 already compiles in a LazyLock with .expect(...) — a bad pattern panics hundreds of other tests first, so this can never be the test that tells you.

5. Absence-only assertions that a broken feature satisfies

  • scala/sbt_cmd.rs:582 test_filter_sbt_test_failures_no_noise — four assert!(!output.contains(...)) and nothing else. filter_sbt_test() returning "" (every failure lost) passes.
  • php/pint_cmd.rs:223 test_pint_invalid_json_falls_back — asserts only !result.contains("pint: ok"). The behaviour in the name, falling back to raw output, is the one thing not asserted; returning "" passes.
  • js/pnpm_cmd.rs:651,660 and cloud/psql_cmd.rs:319,326 — same shape on filter output.

To be fair to the suite: this is 4 OR-assertions in 2,534 tests, no assert!(true)-equivalents, and no commented-out assertions. The vacuity is structural, not careless.

6. Integration tests skip silently when rg is missing

28 sites across the search/grep integration files do if !rg_available() { return; } — an unconditional pass with no skip marker and nothing in the summary. No workflow installs ripgrep (ci.yml:215 installs only tree). On any runner without rg, the search contract self-disables while reporting green.

Tests that are genuinely good — the model to copy

I want to be specific here, because the above is a lot of criticism:

  • git/diff_cmd.rs:430 test_condense_unified_diff_overflow_count_accuracy names the exact old defect in its comment ("changes vec capped at 15, so old code showed +5 more") and asserts the true +190 more. This is the shape everything above is missing.
  • core/guard.rs:15-56 — seven tests pin never_worse on both sides of the boundary plus tie/empty cases, and use the same estimate_tokens production uses. The only savings-adjacent tests whose metric matches the shipped one.
  • tests/guard_integration_test.rs — the one integration file with no cfg(unix); 11 end-to-end process tests asserting exit codes, not just substrings. Ran green here on Windows.
  • discover/registry.rs:1496 and :4319 — regression tests that name the defect they lock ("must FAIL before the fix and PASS after").

Suggested priorities (untested — no programmer has reviewed these)

  1. Make the Windows leg mean something — either port the six files off cfg(unix) or, if they are genuinely POSIX-only, say so and add Windows equivalents, so the matrix does not imply coverage it does not have.
  2. Test the trunk — even a handful of table-driven tests over RULES (given command → expected rewrite) would have caught yadm→git, the find catch-all and the gradle swap in one go.
  3. Use estimate_tokens in savings tests, so the assertions and the tool agree.
  4. Fail loudly rather than silently when rg is absent, and install it in CI.

Activity

  1. pszymkowiak commented on Aug 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 82%

    Summary

    Structural audit finds 53 integration tests are Windows-disabled via #![cfg(unix)], the rewrite RULES table and shared runner.rs have zero tests, and savings tests use word-count instead of the byte-based estimate_tokens the tool actually reports — recommend porting/adding Windows tests, table-driving RULES, and aligning test metric with production.

    📁 Relevant files
    • tests/search_faithful_test.rs
    • tests/search_compress_test.rs
    • tests/grep_faithful_format_test.rs
    • tests/grep_context_test.rs
    • tests/search_error_test.rs
    • tests/pipeline_stdin_test.rs
    • src/discover/rules.rs
    • src/core/runner.rs
    • src/core/utils.rs
    • src/core/guard.rs
    • .github/workflows/ci.yml

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. HetCreep commented on Aug 30, 2026

    @HetCreep
    Author

    Correcting my own report, and confirming that nothing in it has been fixed. Re-verified at develop @ 0de9610.

    Provenance: AI-assisted source audit, human-directed, at develop @ 0de9610. Line and test counts were re-counted at this commit; the Windows cargo test --all output was not re-run — see "not checked".

    Strike one figure

    Section 3's "35.6% by words" is wrong and I cannot reconstruct how I arrived at it. The fixture's own word counts, combined with the repo's passing savings >= 50.0 assertion on that same fixture, force a figure of at least 57.5%. Please disregard that number; the surrounding point about which metric is used still stands, but the arithmetic supporting it does not.

    One item to drop from the list

    src/cmds/system/deps.rs should come off the "also zero tests" list — it now has 3. In fairness those tests are collateral of unrelated BOM work and cover one of five summarizers (summarize_package_json_str), leaving run() and the other four at zero, so I am not presenting this as a fix to the issue. It is simply no longer accurate as written.

    Corrected counts, all in the same direction

    • Gated integration tests: 55, not the 53 I reported (six #![cfg(unix)] files).
    • src/discover/rules.rs: 1009 → 1032 lines, still 0 tests.
    • src/core/runner.rs: 286 lines, still 0 tests.
    • Word-based count_tokens definitions: 15.

    The CI matrix cite is unchanged and exact.

    Not checked

    I did not re-run cargo test --all on Windows, so the "six suites print running 0 tests" observation is inferred from the crate-root #![cfg(unix)] rather than observed at this commit.

  3. HetCreep commented on Oct 14, 2026

    @HetCreep
    Author

    Re-checked on v1.0.0 (stable, 2026-10-13): the official release binary plus the v1.0.0 source. Provenance: AI-assisted check, human-directed. "ran" = executed against rtk 1.0.0 with a control; "read" = verified from source only.

    Fixed: src/core/runner.rs now has 39 #[test]s (it had none at the time of the report). Thanks.

    Still live at v1.0.0 (read):

    • tests/*.rs starting with #![cfg(unix)]: 12 files now (curl_stdin, grep_context, grep_faithful_format, init_agent_cursor, init_opencode, native_test_expression, pipeline_stdin, search_compress/error/faithful/stdin, signal_flush), more than the 6 counted originally; they do not run on the Windows job.
    • src/discover/rules.rs has no mod tests (0 tests); src/cmds/system/summary.rs has 0.
    • pipe_cmd.rs:652,675 assert savings >= 40.0 // TODO; search.rs:1854 is a tautology (per_file + 42 - per_file); mvn_cmd.rs:4971 print_savings_summary is #[ignore] with no assertion.
    • ci.yml:284 installs ripgrep only in the benchmark job, so the rg_available skips apply in the test job.

    Correction to the original text: the "35.6% by words" figure in section 3 was wrong when written (the fixture's own word counts force at least 57.5%); I have not re-measured it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions