[RFC] CMake: Capture stderr when running tests.

A possible fix for #1301, based on @Islah's last comment there.
Maybe one could just disable the EMSG*-macros for the unit test environment? I'm not sure if they could help in any way during the tests.