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

Open Beginner friendly
#3,251 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
79/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp

Research direction

Start with extras/CatchAddTests.cmake, where the issue says the listing path is passed to the test executable as a separate argument. Check how catch_discover_tests constructs the --out argument and how the failing Wine invocation parses it. Update the argument so the path is accepted, then verify discovery succeeds for Windows test executables run under Wine.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C++
Stars
21.6k
Forks
3.4k
Avg merge
3d 12h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from catchorg/Catch2

All issues in catchorg/Catch2

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.