Skip to content

How it works

  1. trimtest record snapshots every file by a semantic fingerprint (the token stream without comments and whitespace, where a grammar exists) and caches each file’s imports in .trimtest/map.json.
  2. trimtest select diffs the tree against that map, so uncommitted edits and stale branches work. It walks the reverse dependency graph from every changed file and prints the tests it reaches, with a reason chain. --base <ref> compares against git instead and needs no map.
  3. trimtest run selects, then invokes each project’s native runner with a filter.

Because the fingerprint ignores comments and formatting, reformatting a file or editing a comment selects nothing.

Every selected test carries one or more reasons, and trimtest explain prints all of them:

Reason Meaning
test changed the test file itself changed
new test the test file did not exist when the baseline was recorded
a.py -> tests/test_a.py a changed file is imported (directly or transitively) by the test
executes a.py (recorded) a recording shows the test ran code in the changed file
failed last run the test failed last time, so it always runs again first
a full-run reason a safety rule selected the whole project, and the reason says which

Each selected test also records the tier of its evidence: static (import graph), recorded (coverage measurement), rule (configuration) or full (the whole suite was selected). See Static vs recorded tier.

Fixtures and data files select tests whose source mentions the file name.

It never guesses. See Safety rules for the cases where the whole suite runs instead.