CMake: Assert stderr when running tests.

Fix #1301.