In sh's [] command, you should use =, not ==. I got away with this because bash accepts ==, but that's non-portable.
This fails if you make test *twice* without the preceding patch. Unfortunately I couldn't find a good way to make it fail if you only make test once.