Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct argument references in CatchAddTests.cmake #2747

Merged
merged 1 commit into from Sep 25, 2023

Conversation

xandox
Copy link
Contributor

@xandox xandox commented Sep 20, 2023

In case when using DISCOVERY_MODE PRE_TEST and some REPORTER in catch_discover_tests
catch_discover_tests_impl fails with error

CMake Error at Catch2/CatchAddTests.cmake:101 (message):
  Error running test executable '':

    Result: No such file or directory
    Output: 

due wrong names for arguments

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #2747 (db495ac) into devel (9c541ca) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##            devel    #2747   +/-   ##
=======================================
  Coverage   91.36%   91.36%           
=======================================
  Files         190      190           
  Lines        7855     7855           
=======================================
  Hits         7176     7176           
  Misses        679      679           

@horenmar
Copy link
Member

Thanks, the changes look correct, but I cannot reproduce the issue on my end.

I cloned Catch2 at current devel commit, and made small reproducer:

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.20)

project(test-discover-tests LANGUAGES CXX)

add_subdirectory(Catch2)

add_executable(tests tests.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)

include(Catch)

enable_testing()
catch_discover_tests(tests
  DISCOVERY_MODE PRE_TEST
)
$ cat tests.cpp
#include <catch2/catch_test_macros.hpp>

TEST_CASE("abc") {}
TEST_CASE("def") {}
TEST_CASE("ghi") {}
$ cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug && ninja -C build && cd build && ctest
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_FLAG__ffile_prefix_map__mnt_c_ubuntu_temp_discover_tests_tests_Catch2__
-- Performing Test HAVE_FLAG__ffile_prefix_map__mnt_c_ubuntu_temp_discover_tests_tests_Catch2__ - Success
-- Configuring done (8.9s)
-- Generating done (5.1s)
-- Build files have been written to: /mnt/c/ubuntu/temp/discover-tests-tests/build
ninja: Entering directory `build'
[109/109] Linking CXX executable tests
Test project /mnt/c/ubuntu/temp/discover-tests-tests/build
    Start 1: abc
1/3 Test #1: abc ..............................   Passed    0.06 sec
    Start 2: def
2/3 Test #2: def ..............................   Passed    0.07 sec
    Start 3: ghi
3/3 Test #3: ghi ..............................   Passed    0.05 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) =   0.41 sec

Can you provide more details on when the tests are not found?

@horenmar horenmar added the Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. label Sep 24, 2023
@xandox
Copy link
Contributor Author

xandox commented Sep 25, 2023

Hello @horenmar.

It's not clearly viewed in diff. But if add REPORTER (REPORTER JUnit for example) to your example you will see a error.

@xandox
Copy link
Contributor Author

xandox commented Sep 25, 2023

this if
https://github.com/catchorg/Catch2/pull/2747/files#diff-61b5fe4313696c0a0e502bbfd71ebd640156e2093b4244b28db049241fa2e87eR84

@horenmar
Copy link
Member

I see and can reproduce it now, thanks.

@horenmar horenmar merged commit f161110 into catchorg:devel Sep 25, 2023
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants