Testing subdirectories on commit in that subdirectory

I have a large repo, with a number of tests. It is organized so the tests are with the code in subdirectories. Some of our tests are also quite slow, so we end up with a long-running test for every commit, even though work is often in completely unrelated areas.

I’d like suggestions on how a commit affecting only a subdirectory could run tests only in that directory, so that we don’t have an overwhelming testing situation.