{"record":{"id":"e15deb8ee13c46bd","repo":"rtk-ai/rtk","slug":"filter-s-have-no-inline-tests-use-require-a","errorCode":null,"errorMessage":"{} filter(s) have no inline tests (use --require-all in CI)","messagePattern":"(.+?) filter\\(s\\) have no inline tests \\(use --require-all in CI\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/verify_cmd.rs","lineNumber":38,"sourceCode":"        if !outcome.passed {\n            eprintln!(\n                \"FAIL [{}] {}\\n  expected: {:?}\\n  actual:   {:?}\",\n                outcome.filter_name, outcome.test_name, outcome.expected, outcome.actual\n            );\n        }\n    }\n\n    if total == 0 {\n        println!(\"No inline tests found.\");\n    } else {\n        println!(\"{}/{} tests passed\", passed, total);\n    }\n\n    if require_all && !results.filters_without_tests.is_empty() {\n        for name in &results.filters_without_tests {\n            eprintln!(\"MISSING tests for filter: {}\", name);\n        }\n        anyhow::bail!(\n            \"{} filter(s) have no inline tests (use --require-all in CI)\",\n            results.filters_without_tests.len()\n        );\n    }\n\n    if failed > 0 {\n        anyhow::bail!(\"{} test(s) failed\", failed);\n    }\n\n    Ok(())\n}\n","sourceCodeStart":20,"sourceCodeEnd":50,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/verify_cmd.rs#L20-L50","documentation":"`rtk verify` runs inline tests embedded in TOML custom filters. With the --require-all flag (intended for CI), the command additionally fails when any discovered filter has no inline tests at all, listing each such filter on stderr before bailing. This enforces test coverage for every custom filter so untested output-rewriting rules cannot ship.","triggerScenarios":"Running `rtk verify --require-all` when `run_filter_tests` reports non-empty `filters_without_tests` — i.e. at least one TOML filter is loaded but defines no inline [[tests]] entries. Optionally scoped by passing a filter name; the check applies to whatever set of filters is evaluated.","commonSituations":"Adding a new filter to .rtk/filters.toml without writing its inline tests, then running the CI verify gate; upgrading rtk where --require-all was newly added to the CI script; reusing a filter copied from elsewhere that never had tests.","solutions":["Add inline tests to each listed filter in the TOML file (test entries with input/expected output) until `rtk verify --require-all` passes.","Run `rtk verify` without --require-all locally to see pass/fail counts, then fix only the MISSING-tests filters listed on stderr.","If a filter is intentionally test-free (e.g. experimental), drop --require-all from the CI invocation or exclude that filter from the verified set.","Check that the tests are in the correct TOML section/format so they are discovered — malformed test entries may count as 'no tests'."],"exampleFix":"// before: filter with no tests\n[filters.my-filter]\npattern = \"warning: .*\"\n\n// after: add an inline test\n[filters.my-filter]\npattern = \"warning: .*\"\n\n[[filters.my-filter.tests]]\ninput = \"warning: slow build\"\nexpected = \"warning: slow build\"","handlingStrategy":"validation","validationCode":"import re, pathlib\n\ndef filters_missing_tests(toml_text):\n    # heuristic: every [filters.<name>] section should be followed by a [[filters.<name>.tests]] block\n    names = re.findall(r'^\\[filters\\.([\\w-]+)\\]', toml_text, re.M)\n    missing = [n for n in names if f\"[[filters.{n}.tests]]\" not in toml_text]\n    return missing\n\ntext = pathlib.Path(\".rtk/filters.toml\").read_text()\nmissing = filters_missing_tests(text)\nif missing:\n    raise SystemExit(f\"add inline tests for: {missing}\")","typeGuard":null,"tryCatchPattern":"import subprocess\nr = subprocess.run([\"rtk\", \"verify\", \"--require-all\"], capture_output=True, text=True)\nif r.returncode != 0 and \"have no inline tests\" in r.stderr:\n    print(\"Coverage gate failed:\", r.stderr)\n    # decide: add tests or run without --require-all locally\nelse:\n    raise RuntimeError(r.stderr)","preventionTips":["Treat inline tests as part of the definition of done for every new TOML filter.","Run `rtk verify --require-all` locally before pushing, mirroring the CI gate.","When copying a filter from elsewhere, copy its tests too.","Add a repo check (script or CI step) that fails early if a [filters.*] section lacks a [[tests]] block."],"tags":["ci","testing","filters","toml"],"backgroundTag":"empty-required-field","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}