pre-commit more or less does this. When you install locally as a git hook it will only test on changes that are being committed.
I've been impressed by Pants (Python build tooling) which manages this really well https://www.pantsbuild.org/docs/advanced-target-selection#ru...
I wish it was more nuanced
cmnv = commit --no-verify