Skip to content

[CMake]Optimize JSON parsing in catch_discover_tests()#3169

Merged
horenmar merged 1 commit into
catchorg:develfrom
TheStormN:issue-3168-optimize-catch_discover_tests
Jul 8, 2026
Merged

[CMake]Optimize JSON parsing in catch_discover_tests()#3169
horenmar merged 1 commit into
catchorg:develfrom
TheStormN:issue-3168-optimize-catch_discover_tests

Conversation

@TheStormN

Copy link
Copy Markdown
Contributor

Description

Optimizes the CMake JSON parsing logic in catch_discover_tests() by avoiding materialization of full per-test JSON object when ADD_TAGS_AS_LABELS is not used.

GitHub Issues

Closes #3168

@TheStormN TheStormN force-pushed the issue-3168-optimize-catch_discover_tests branch from 3dc07b0 to 6c2b6b9 Compare July 7, 2026 22:10
Comment on lines +202 to +208
if(add_tags)
string(JSON single_test GET "${test_listing}" ${idx})
string(JSON test_tags GET "${single_test}" "tags")
string(JSON plain_name GET "${single_test}" "name")
else()
string(JSON plain_name GET "${test_listing}" ${idx} "name")
endif()

@TheStormN TheStormN Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short if add_tags is false we do only a single round of parsing the JSON data. Unfortunately if tags are used as labels, the performance will be as before.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.12%. Comparing base (191fa38) to head (6c2b6b9).

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #3169   +/-   ##
=======================================
  Coverage   91.12%   91.12%           
=======================================
  Files         204      204           
  Lines        8922     8922           
=======================================
  Hits         8130     8130           
  Misses        792      792           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@horenmar horenmar added the Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. label Jul 8, 2026
@horenmar

horenmar commented Jul 8, 2026

Copy link
Copy Markdown
Member

Sure, why not.

@horenmar horenmar merged commit a15f718 into catchorg:devel Jul 8, 2026
88 checks passed
@TheStormN TheStormN deleted the issue-3168-optimize-catch_discover_tests branch July 8, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The new JSON parsing in catch_discover_tests() is really slow.

2 participants