conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] test_requires in conanfile.txt

Open magras opened this issue 3 years ago • 3 comments

I've mistakenly used [build_requires] for gbench framework until I tried to compare my implementation to boost and found #9951 issue. If I understand correctly force_host_context has been deprecated. And I don't know how to specify it inside .txt, if at all possible.

Should I use regular [requires] for test and benchmark frameworks like gtest and gbench? Or does it make sense to add [test_requires] section to conanfile.txt?

magras avatar Apr 29 '22 01:04 magras

Hi @magras

Yes, for a simple conanfile.txt, a requirement to a test library, like gtest or catch, is completely equivalent to a regular requires, so it can go directly in the [requires] section (and it shouldn't go in the [tool_requires], because the behavior will be different).

We might eventually add a [test_requires] section, but it would be purely syntactic sugar, no functional difference. Will put this for discussion for 2.X

memsharded avatar Apr 29 '22 07:04 memsharded

Thank you for your answer.

Will put this for discussion for 2.X

Then I'll leave this issue open for now.

magras avatar Apr 29 '22 19:04 magras

Would a [test_requires] section be equivalent to a test_requires attribute in the conanfile.py ?

tool_requires has an attribute, but seemingly a test_requires attribute is also missing there too.

thorntonryan avatar Aug 04 '22 21:08 thorntonryan

We finally did implement [test_requires] in conanfile.txt, it is already part of the released 2.0. Closing this as resolved, feedback welcome.

memsharded avatar Feb 27 '23 17:02 memsharded