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

CTest (using catch_discover_tests) treats skipped tests as failed #2873

Closed
jonathanverner opened this issue May 20, 2024 · 2 comments
Closed
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.

Comments

@jonathanverner
Copy link

Describe the bug
When using CMake integration to auto-discover tests and run them with CTest, tests which are skipped are reported as failed.

Expected behavior
Skipped tests are reported as skipped.

Platform information:

  • OS: Linux (Neon 22.04, based on Ubuntu 22.04)
  • Compiler+version: 17.0.6
  • Catch version: v3.3.2

Additional context
I think the reason is that ctest runs the tests one-by-one and if a test is skipped, this actually means that no test was run so, since --allow-running-no-tests is not provided, the return code is non-zero.

Now, CTest allows marking skipped tests via a special return code by setting the SKIP_RETURN_CODE property on the test. So, it seems to me, this could be fixed by replacing the

set(properties ${TEST_PROPERTIES})

line in CatchAddTests.cmake with

set(properties "${TEST_PROPERTIES};SKIP_RETURN_CODE;4")

This works for me as does passing SKIP_RETURN_CODE 4 to catch_discover_tests PROPETIES argument, e.g. like so:

catch_discover_tests(middleware_tests
  PROPERTIES
    SKIP_RETURN_CODE 4
)
fredemmott added a commit to fredemmott/bindline that referenced this issue Aug 6, 2024
@fredemmott
Copy link

This ties into #1146 : unfortunately using SKIP_RETURN_CODE 4 means that if your test has 4 failed CHECK() invocations, CTest will consider it to be skipped.

@fredemmott
Copy link

For now I'm using SKIP_REGULAR_EXPRESSION "[1-9][0-9]* skipped"

@horenmar horenmar added the Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. label Sep 17, 2024
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

No branches or pull requests

3 participants