How it works
trimtest recordsnapshots 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.trimtest selectdiffs 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.trimtest runselects, 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.
What counts as a reason
Section titled “What counts as a reason”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 |
Evidence tiers
Section titled “Evidence tiers”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.
Non-code files
Section titled “Non-code files”Fixtures and data files select tests whose source mentions the file name.
When trimtest cannot tell
Section titled “When trimtest cannot tell”It never guesses. See Safety rules for the cases where the whole suite runs instead.