Add new tests, and fix one cause of rules being run extra times.
In directory targets, track paths we know about and check against them.

This partially fixes for files disappearing.  Unfortunately, it's
unlikely to be much use recursively.