catch_discover_tests fails for Emscripten/WASM tests since v3.16.0

Open
#3,241 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@nafiurahman00 is already working on this.

Since Nov 19, 2026.

  • #3242 by @nafiurahman00 — open
  • #3246 by @17kaushalsingh — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp, node.js, wasm

Research direction

Start with extras/CatchAddTests.cmake, especially the test listing logic around the temporary --out file, and compare it with the earlier stdout-based behavior mentioned in the issue. Reproduce using an Emscripten-built test executable registered with catch_discover_tests() and run ctest. Done means discovery succeeds when the executor cannot write to the host filesystem while preserving the existing discovery behavior.

Written by the indexing model from the issue text.

Description

Extras

Describe the bug

After updating from Catch2 3.13.0 to 3.16.1, catch_discover_tests() fails for our WebAssembly test executables built with Emscripten and run via Node.js (CMAKE_CROSSCOMPILING_EMULATOR set by the Emscripten toolchain):

Error when creating reporter: Unable to open file: '/home/conan/p/b/vcdb150102452536/b/cmake-build/RelWithDebInfo/source/vcd/test/Catch2-test-listing.Y01TSK3K.json'
CMake Error at /home/conan/p/catch47fa9efe01a8b/p/lib/cmake/Catch2/CatchAddTests.cmake:307 (message):
  Error listing tests from executable
  '/home/conan/p/b/vcdb150102452536/b/cmake-build/RelWithDebInfo/bin/vcd-test.js':

    Result: 6
    Output:

I think this was introduced by 9ec44dd62 (fix for #3162), which makes the test executable write the listing into a temp file via --out instead of reading stdout:

https://github.com/catchorg/Catch2/blob/v3.16.1/extras/CatchAddTests.cmake#L296-L304

An Emscripten executable only sees its virtual in-memory filesystem by default, so it cannot write to the path on the host. Stdout is forwarded by Node, which is why it worked before.

Expected behavior

Test discovery works with executors that don't share the host filesystem, like it did up to 3.15.x. Maybe a fallback to stdout or an option to opt out of the temp file?

Reproduction steps

Any test executable built with the Emscripten toolchain and registered with catch_discover_tests(), then run ctest.

Platform information:

  • OS: Linux (Ubuntu), target wasm64
  • Compiler+version: Emscripten 5.0.7, Node.js 24.18.0, CMake 4.3.2
  • Catch version: v3.16.1 (works with v3.13.0)
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.