Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conan, CMake.test() generate XML report

Tags:

c++

conan

I am currently in the process of introducing Conan.io (Version 1.20.5) to my project.

With Cmake.test(), I am missing the XML testreport that was previously generated by calling ctest -T test directly.

Here is the conanfile.py build() excerpt:

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

Comments:

1.) Defining args to the build() is breaking the build as these args seem to be forwarded to _build(): https://github.com/conan-io/conan/blob/812c8ec8185e24b2bc41fb6e855d35c925526670/conans/client/build/cmake.py#L276

Regards, Christian

like image 392
chris polzer Avatar asked Mar 03 '23 23:03

chris polzer


1 Answers

You want to pass an argument to ctest, but Conan calls cmake --build . --target test instead of ctest directly, thus you need to pass as extra argument:

def build(self):
    cmake = CMake(self)
    cmake.configure()
    cmake.build()
    cmake.test(args=['--', 'ARGS=-T Test'])

This will result in the follow command:

> cmake --build '/tmp/foo/test_package/build/878b1b6e2d4cbc82452d014e37c38868584457e8' '--target' 'test' 'ARGS=-T Test' '--' '-j4'

Now you will have the XML file result.

Regards!

like image 81
uilianries Avatar answered Mar 18 '23 12:03

uilianries