[RFC] CMake: Capture stderr when running tests.

A possible fix for #1301, based on @Islah's last comment there.
Great, you tracked it down! If this can be fixed in another PR, I'm not sure if this PR is even necessary. We could keep it in case something like this happens again, maybe even change it to fail *if* there's output to stderr.