JSON failed parsing json string

Aperta
#2,999 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cmake, cpp

Direzione di ricerca

Inizia da lib/cmake/Catch2/CatchAddTests.cmake, in particolare dal parsing JSON intorno alle righe 138 e 235 e dalla modifica del commit 7d7b2f89f24cbd277f6eb6912705e5e13c68a3c7. Riproduci la scoperta dei test con l’output di Catch riportato su CMake 3.22.1 o 3.25.1 e ispeziona listing_output prima del parsing. Il lavoro è completo quando catch_discover_tests termina senza l’errore di parsing JSON sulle piattaforme riportate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
.

Lingua principale
C++
Stelle
21.6k
Fork
3.4k
Merge medio
3g 12h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di catchorg/Catch2

Tutte le issue di catchorg/Catch2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.