catch_discover_tests passes all EXTRA_ARGS as one argument

オープン 初心者向け
#3,239 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@CyberKun がすでに取り組んでいます。

2026年11月16日 から。

  • #3240 @CyberKun による — オープン
  • #3247 @17kaushalsingh による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cmake, cpp
領域
testing

調査の方向性

extras/Catch.cmake から取り込まれる Catch の CMake 統合から始め、catch_discover_tests が EXTRA_ARGS を生成されたテストコマンドに渡す方法をたどってください。再現例では、引数がセミコロンで結合され、1 つのトークンとしてバイナリに渡されます。各値を個別の引数として保持し、次に、提供された CMake の再現例が ctest で成功することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
A clear and concise description of what the bug is.

catch_discover_tests joins all EXTRA_ARGS values into one argument, separated by ;. A test registered with EXTRA_ARGS --colour-mode ansi fails:

Error(s) in input:
  Unrecognised token: --colour-mode;ansi

Expected behavior
A clear and concise description of what you expected to happen.

Each EXTRA_ARGS value reaches the test binary as its own argument.

Reproduction steps
Steps to reproduce the bug.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(catch2-extra-args CXX)

set(CATCH2_TAG v3.16.1 CACHE STRING "Catch2 git tag to test")
include(FetchContent)
FetchContent_Declare(Catch2
  GIT_REPOSITORY https://github.com/catchorg/Catch2.git
  GIT_TAG ${CATCH2_TAG}
  GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)

include(CTest)
include(Catch)
add_executable(colour_test colour_test.cpp)
target_link_libraries(colour_test PRIVATE Catch2::Catch2WithMain)
catch_discover_tests(colour_test EXTRA_ARGS --colour-mode ansi)

colour_test.cpp:

#include <catch2/catch_test_macros.hpp>
TEST_CASE("extra arguments reach the test binary") { REQUIRE(true); }
$ cmake -B build-v3.16.1 -G Ninja -DCATCH2_TAG=v3.16.1 && cmake --build build-v3.16.1 && ctest --test-dir build-v3.16.1 --output-on-failure
-- The CXX compiler identification is GNU 16.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/ii6p6kc1brz3vycqg88q4zb4xd2dmqwp-gcc-wrapper-16.2.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_FLAG__ffile_prefix_map__home_reap_Desktop_nixpkgs_catch2_extra_args_build_v3_16_1__deps_catch2_src__
-- Performing Test HAVE_FLAG__ffile_prefix_map__home_reap_Desktop_nixpkgs_catch2_extra_args_build_v3_16_1__deps_catch2_src__ - Success
-- Configuring done (1.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/reap/Desktop/nixpkgs/catch2-extra-args/build-v3.16.1
[112/112] Linking CXX executable colour_test
Test project /home/reap/Desktop/nixpkgs/catch2-extra-args/build-v3.16.1
    Start 1: extra arguments reach the test binary
1/1 Test #1: extra arguments reach the test binary ...***Failed    0.00 sec

Error(s) in input:
  Unrecognised token: --colour-mode;ansi

Run with -? for usage



0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.00 sec

The following tests FAILED:
          1 - extra arguments reach the test binary (Failed)
Errors while running CTest

Platform information:

  • OS: NixOS, Linux x86_64
  • Compiler+version: GCC 16.2.0, CMake 4.4.4
  • Catch version: v3.16.1, and devel at 36c1bc3ef209

Additional context
Add any other context about the problem here.

I found this issue while working on https://github.com/NixOS/nixpkgs/pull/587421

主要言語
C++
スター
21.6k
フォーク
3.4k
平均マージ
3日 12時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

catchorg/Catch2 のほかの issue

catchorg/Catch2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。