Skip to content

tests_covering

Answers the question “which tests exercise internal/foo/bar.go?” so the agent can scope run_tests or run_failing_tests to the minimum packages that matter — rather than rerunning the whole suite after every edit.

The session coverage index is populated by run_tests on every Go run and queried by tests_covering. No extra test run is needed.

ParamTypeRequiredDefault
filestringyesWorkspace-relative path to the source file (e.g. internal/tools/read.go).
linenumberno1-based line. Omitted = any line in the file.
  1. If the coverage index isn’t configured on the server → error.
  2. If no run_tests call has produced coverage yet in this session → text result no coverage data yet — run run_tests first.
  3. If file is missing or blank → error.
  4. If file has no entry in the index → text result no coverage found for <file>.
  5. If line is set but no test covers that line in the file → text result no coverage found for <file>:<line>.
  6. Otherwise → a text block listing the covering tests, grouped by Go import path, capped at 200 entries with a ... (N more truncated) footer (same style as last_test_failures).

Attribution is package-level, not per-test.

Go’s standard -coverprofile=<path> is a per-run aggregate — it doesn’t split coverage per individual test. For each profile record that touched a source file, tests_covering attributes every test that ran in that file’s package during the same run. In practice this is the right unit of work for an agent: reruns happen per-package anyway via go test -run '^TestX$' <pkg>.

Splitting coverage per test would require running tests one-at-a-time with -run ^TestX$ -coverprofile, which is expensive and defeats the point of targeted reruns.

  • Go — supported. The Go detector’s go test -json -count=1 is augmented with -coverprofile=<tempfile> on every run_tests invocation; the profile is parsed, ingested into the session index, and the tempfile is removed.
  • Node / Python / Rust — not yet wired. run_tests on these languages leaves the index empty, so tests_covering returns no coverage data yet.

After a passing Go run:

{"tool": "run_tests"}

Find the tests covering a file:

{"tool": "tests_covering", "arguments": {"file": "internal/tools/read.go"}}

Sample output:

3 test(s) cover internal/tools/read.go:
github.com/altairalabs/codegen-sandbox/internal/tools:
TestRead_ReturnsNumberedLines
TestRead_OffsetAndLimit
TestRead_MarksFileAsRead

Scope to a specific line:

{"tool": "tests_covering", "arguments": {"file": "internal/tools/read.go", "line": 42}}
  • Session-scoped. Process-local; no persistence across restarts.
  • Overwritten on every run_tests call (same contract as the structured-failure store). There is no merged history.