Skip to content

catch_discover_tests() should process only json portion of stdout #3162

Closed

Description

@TheStormN

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.

Activity

  1. ShivaPriyanShanmuga commented on Jun 20, 2026

    @ShivaPriyanShanmuga

    I’d like to work on this issue if it’s still open. Could you assign it to me?

  2. horenmar commented on Jul 3, 2026

    @horenmar
    Member

    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.

  3. added
    Extras
    on Jul 3, 2026
  4. TheStormN commented on Jul 3, 2026

    @TheStormN
    ContributorAuthor

    @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?

  5. horenmar commented on Jul 4, 2026

    @horenmar
    Member

    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.

  6. added a commit that references this issue on Jul 4, 2026
    9ec44dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Extras

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions