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

[feature] Add better CTest support to CMake helper #14798

Closed
1 task done
fschoenm opened this issue Sep 21, 2023 · 3 comments · Fixed by #15282
Closed
1 task done

[feature] Add better CTest support to CMake helper #14798

fschoenm opened this issue Sep 21, 2023 · 3 comments · Fixed by #15282
Assignees
Milestone

Comments

@fschoenm
Copy link

What is your suggestion?

Right now, the CMake helper has a test() method that uses the test/RUN_TESTS target for running tests. However, CTest has a lot of additional options that cannot be configured with just environment variables (see https://cmake.org/cmake/help/latest/manual/ctest.1.html).

For example, it does not seem possible to set the --output-junit parameter that way. But there are a lot more parameters that cannot be used, e.g. excluding and include tests, repeated runs, etc.

I think it would be nice to have an additional ctest() method that uses CTest directly instead of the limited method above. It should be possible to use presets anyway, so calling e.g. ctest --preset conan-debug on the command already starts CTest with the correct preset.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@jcar87 jcar87 self-assigned this Sep 21, 2023
@jcar87 jcar87 added this to the 2.0.12 milestone Sep 21, 2023
@jcar87
Copy link
Contributor

jcar87 commented Sep 21, 2023

Hi @fschoenm - thank you for raising this issue.

Thank you for pointing out a use case where the recommended approach (environment variables) is not suitable.
Will discuss this with the team to try and improve the interface to cover this.

@czoido czoido modified the milestones: 2.0.12, 2.0.13, 2.0.14 Sep 26, 2023
@PeteAudinate
Copy link

PeteAudinate commented Sep 30, 2023

You can use CMAKE_CTEST_ARGUMENTS:

 def generate(self):
        deps = CMakeDeps(self)
        deps.generate()

        tc = CMakeToolchain(self)
        ctest_args = "--output-on-failure;--output-junit;test_results.xml"
        tc.cache_variables["CMAKE_CTEST_ARGUMENTS"] = ctest_args
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()
        cmake.test()

But it would be nice to have a cmake.ctest() method.

@memsharded
Copy link
Member

Implemented in #15282, for next 2.0.15, feedback welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants