JSON failed parsing json string
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cmake, cpp
- Domain
- build-system, testing
Research direction
Start in lib/cmake/Catch2/CatchAddTests.cmake, especially the JSON parsing around lines 138 and 235 and the change from commit 7d7b2f89f24cbd277f6eb6912705e5e13c68a3c7. Reproduce test discovery with the reported Catch output on CMake 3.22.1 or 3.25.1 and inspect listing_output before parsing. Done means catch_discover_tests completes without the JSON parsing error on the reported platforms.
Written by the indexing model from the issue text.
Description
Describe the bug
I am recently getting the following error with latest devel release (ceed2684):
CMake Error at /path/to/Catch2/lib/cmake/Catch2/CatchAddTests.cmake:138 (string):
string sub-command JSON failed parsing json string: * Line 1, Column 6
Missing ',' or ']' in array declaration
.
Call Stack (most recent call first):
/path/to/Catch2/lib/cmake/Catch2/CatchAddTests.cmake:235 (catch_discover_tests_impl)
Line 138 of CatchAddTests.cmake is:
string(JSON version GET "${listing_output}" "version")
adding a CMake message just before the line for the value listing_output yields:
{
"version": 1,
"metadata": {
"name": "ut_saccades_frameworkd",
"rng-seed": 994172703,
"catch2-version": "3.8.1"
},
"listings": {
"tests": [
{
Expected behavior
I've isolated the commit which causes the error:
7d7b2f89f24cbd277f6eb6912705e5e13c68a3c7
Support adding test tags as CTest labels in catch_discover_tests
which does indeed add those lines to CatchAddTests.cmake.:
- # Parse output
- foreach(line ${output})
- set(test "${line}")
+ # Parse JSON output for list of tests/class names/tags
+ string(JSON version GET "${listing_output}" "version")
+ if (NOT version STREQUAL "1")
+ message(FATAL_ERROR "Unsupported catch output version: '${version}'")
+ endif()
+
+ # Speed-up reparsing by cutting away unneeded parts of JSON.
+ string(JSON test_listing GET "${listing_output}" "listings" "tests")
+ string(JSON num_tests LENGTH "${test_listing}")
+ # CMake's foreach-RANGE is inclusive, so we have to subtract 1
+ math(EXPR num_tests "${num_tests} - 1")
Reproduction steps
Haven't done this yet but will try to reproduce with small example if necessary.
Platform information:
- Windows 11:
- Visual Studio Community 17.4.3
- CMake: 3.25.1
- Ubuntu 22.04:
- gcc: 11.4
- CMake: 3.22.1
- Catch: ceed2684
Additional context
.
- Dominant language
- C++
- Stars
- 21.6k
- Forks
- 3.4k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from catchorg/Catch2
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 2 days
-
catch_discover_tests passes all EXTRA_ARGS as one argumentPossibly taken @CyberKun claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
catchorg/Catch2#3239 · 1 comment ·
Maintainers usually reply within 2 days
-
Not seeing some error messages from fakeit in jetbrains riderPossibly taken @Amanpal9 claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
catchorg/Catch2#3228 · 1 comment ·
Maintainers usually reply within 2 days
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0Possibly taken @nafiurahman00 claimed this 8 days ago. OpenExtras
Difficulty 3/5 1-2 days Newbie friendliness 72/100
catchorg/Catch2#3241 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cp-algorithms/cp-algorithms#1774 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
telefonicaid/fiware-orion#4836 ·
Maintainers usually reply within 1 day
-
nixd exits at startup when its parent process belongs to another userPossibly taken @conao3 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nix-community/nixd#930 ·
Maintainers usually reply within 2 days
-
refactor topic-ui topic-weather
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Command-Install Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/winget-cli#6718 ·
Maintainers usually reply within 2 days