Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Document that DISCOVERY_MODE PRE_TEST should be used with catch_discover_tests when used with XCode.

This addresses https://github.com/catchorg/Catch2/issues/2411 by making the "workaround" the official approach and is consistent with how gtest and cmake deal with the same situation.
Commit
eb431764b4cb9b6fa2296a034b4231064f8e464e
Author
Phil Nash ·
Committer
Martin Hořeňovský
Parents
ae5d271da2c8

Files · Download .tar.gz

Changes

 docs/cmake-integration.md | 11 +++++++++++
 extras/Catch.cmake        |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md
index e63e67f6..63b5ebde 100644
--- a/docs/cmake-integration.md
+++ b/docs/cmake-integration.md
@@ -212,6 +212,17 @@ execution (useful e.g. in cross-compilation environments).
 calling ``catch_discover_tests``. This provides a mechanism for globally
 selecting a preferred test discovery behavior.
 
+_Note that on Apple Silicon with the Xcode generator you must use `PRE_TEST`,
+e.g. `catch_discover_tests(tests DISCOVERY_MODE PRE_TEST)`. With the default
+`POST_BUILD` mode the build fails with `Result: Subprocess killed`, because
+macOS on Apple Silicon refuses to run unsigned binaries and Xcode code-signs
+the test executable only **after** the post-build script that `POST_BUILD`
+mode uses to run it for test discovery. `PRE_TEST` avoids this by delaying
+discovery until test time, when the executable is already signed. The same
+limitation affects CMake's `gtest_discover_tests`; see
+[Catch2 #2411](https://github.com/catchorg/Catch2/issues/2411) and
+[CMake #21845](https://gitlab.kitware.com/cmake/cmake/-/issues/21845)._
+
 * `SKIP_IS_FAILURE`
 
 Skipped tests will be marked as failed instead.
diff --git a/extras/Catch.cmake b/extras/Catch.cmake
index 657bb724..9426f67f 100644
--- a/extras/Catch.cmake
+++ b/extras/Catch.cmake
@@ -146,6 +146,12 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
     calling ``catch_discover_tests``. This provides a mechanism for globally selecting
     a preferred test discovery behavior without having to modify each call site.
 
+    On Apple Silicon with the Xcode generator you must use ``PRE_TEST``. With the
+    default ``POST_BUILD`` mode the build fails with ``Result: Subprocess killed``,
+    because macOS on Apple Silicon refuses to run unsigned binaries and Xcode
+    code-signs the test executable only after the post-build script that
+    ``POST_BUILD`` mode uses to run it for test discovery. See Catch2 issue #2411.
+
   ``SKIP_IS_FAILURE``
     Disables skipped test detection.