ninja: add support for build-time tests

Sorry for the indentation.

The tests went really fast at my mac. The whole time of building ninja with these checks was 13 seconds and most of it was spent on compilation.
```
🍺  /usr/local/Cellar/ninja/1.5.1: 6 files, 260K, built in 13 seconds
```