You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
catch_discover_tests() should process only json portion of stdout #3162
Describe the bug
I'm trying to update a CMake based project from Catch 3.7.1 to 3.15.1. It seems in recent versions of Catch, the catch_discover_tests() is now using json output for registering the tests. However, we have a 3rd party libraries which are doing static object initialization which are printing stuff to stdout like "Started up succesfully", etc. This is effectively breaking the json parser as it considers this info to be part of the tests output, Before that was not the case as such things were quietly ignored.
Expected behavior
As it is not always possible to address issues coming from 3rd party libraries it would be really nice of the CMake test discovery mechanics just ignore any text which is printed before the json output.
Reproduction steps
Just create a static global variable which prints to stdout from its constructor.
Platform information:
OS: Windows 11
Compiler+version: MSVC 14.44
Catch version: v3.15.1
Additional context
Of course I'm not asking for handling situations where printing happens from other threads during mid-json discovery. It is just about global objects printing stuff from their constructors during startup.
3rd party dependencies is why we can't have nice things. However, #3166 is the wrong way to fix this, the correct way is to have the reporters write into (temp) file and then read that inside CMake.
@horenmar While I agree with you, the fix which is currently proposed is quite simple and effective. Perhaps we can have it until reporters are updated to write to file?
Reporters have supported writing listing into a file for years now. The catch_discover_tests script just used the stdout directly, because it is simpler.
Activity
ShivaPriyanShanmuga commentedon Jun 20, 2026
I’d like to work on this issue if it’s still open. Could you assign it to me?
Ignore non-JSON stdout preamble in catch_discover_tests (catchorg#3162)
horenmar commentedon Jul 3, 2026
3rd party dependencies is why we can't have nice things. However, #3166 is the wrong way to fix this, the correct way is to have the reporters write into (temp) file and then read that inside CMake.
TheStormN commentedon Jul 3, 2026
@horenmar While I agree with you, the fix which is currently proposed is quite simple and effective. Perhaps we can have it until reporters are updated to write to file?
horenmar commentedon Jul 4, 2026
Reporters have supported writing listing into a file for years now. The
catch_discover_testsscript just used the stdout directly, because it is simpler.catch_discover_tests uses tempfile to retrieve JSON from the binary