catch_discover_tests fails for Windows test executables run under Wine since v3.15.2

Aperta Adatta ai principianti
#3,251 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
79/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cmake, cpp

Direzione di ricerca

Inizia da extras/CatchAddTests.cmake, dove secondo l’issue il percorso dell’elenco viene passato all’eseguibile di test come argomento separato. Controlla come catch_discover_tests costruisce l’argomento --out e come lo analizza l’invocazione di Wine che non riesce. Aggiorna l’argomento affinché il percorso venga accettato, quindi verifica che la discovery funzioni per gli eseguibili di test Windows eseguiti con Wine.

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

Descrizione

Describe the bug

Since 9ec44dd (the fix for #3162), CatchAddTests.cmake passes the listing temp file as a separate argument: --out "${listing_output_path}". The temp path comes from XDG_RUNTIME_DIR, TMPDIR, TMP or TEMP, so on a Linux host it starts with /.

When the test executable is a Windows binary run through CMAKE_CROSSCOMPILING_EMULATOR (Wine), Clara treats / as an option prefix on Windows (isOptPrefix in catch_clara.cpp). The path is then parsed as a new option rather than the value of --out, and discovery fails:

Error(s) in input:
  Expected argument following --out

CMake Error at .../build/x64/_deps/catch2-src/extras/CatchAddTests.cmake:307 (message):
  Error listing tests from executable
  '.../build/x64/tests/Release/PatchFix.Tests.exe':

Passing the value in the same argument works: wine tests.exe --list-tests --reporter json --out=/tmp/x.json writes the listing, while --out /tmp/x.json fails with the error above.

Expected behavior

Discovery works for Windows executables run under Wine, as it did up to v3.15.1.

Reproduction steps

Reproduced with https://github.com/playday3008/PatchFix at commit 2e2763aae1e57ddb304333fc22a5f741bdc7c2a8, which pins Catch2 v3.15.0 in cmake/deps/catch2.cmake and registers its tests with catch_discover_tests(... DISCOVERY_MODE PRE_TEST). The commands below follow its Linux CI job runs; the toolchain needs LLVM, Ninja, Wine and msvc-wine installed to ~/.msvc.

git clone https://github.com/playday3008/PatchFix && cd PatchFix
git checkout 2e2763aae1e57ddb304333fc22a5f741bdc7c2a8
sed -i 's/v3.15.0/v3.16.1/' cmake/deps/catch2.cmake
cmake --preset wine-x64
cmake --build --preset wine-x64-release --target PatchFix.Tests
ctest --test-dir build/x64 -C Release --output-on-failure --no-tests=error

With v3.15.0 or v3.15.1, ctest passes. With v3.15.2, v3.15.3, v3.16.0 or v3.16.1, it fails with the error above.

Possible fix

Pass the path in one argument in CatchAddTests.cmake, for example "--out=${listing_output_path}", so parsing no longer depends on the first character of the path.

Platform information:

  • OS: Linux host (Fedora), Windows x64 target run under Wine 11.0 (Staging)
  • Compiler+version: clang-cl 22.1.8 with MSVC headers and libraries via msvc-wine
  • Catch version: v3.15.2 through v3.16.1 fail; v3.15.1 works

Additional context

Same origin as #3241 (Emscripten), but a different cause; the stdout options proposed there would not fix this by default.

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.