Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference/conanfile/attributes/requirements.inc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ won't be retrieved. They cannot conflict.
.. code-block:: python

class MyPkg(ConanFile):
test_requires = "gtest/1.11.0", "other_test_tool/0.2@user/testing"
test_requires = "gtest/1.17.0", "other_test_tool/0.2@user/testing"


This is the declarative way to add ``test_requires``.
Expand Down
13 changes: 9 additions & 4 deletions tutorial/creating_packages/build_packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Changes introduced in the recipe

.. code-block:: python
:caption: *conanfile.py*
:emphasize-lines: 12, 19, 33-34
:emphasize-lines: 12, 20-21, 35

class helloRecipe(ConanFile):
name = "hello"
Expand All @@ -51,7 +51,9 @@ Changes introduced in the recipe
def requirements(self):
if self.options.with_fmt:
self.requires("fmt/8.1.1")
self.test_requires("gtest/1.11.0")

def build_requirements(self):
self.test_requires("gtest/1.17.0")

...

Expand All @@ -73,8 +75,11 @@ Changes introduced in the recipe

...

* We added the *gtest/1.11.0* requirement to the recipe as a ``test_requires()``. It's a
type of requirement intended for testing libraries like **Catch2** or **gtest**.
* We added the *gtest/1.17.0* requirement to the recipe as a
``test_requires()``. It's a type of requirement intended for testing libraries
like **Catch2** or **gtest**, and we declare it inside the
``build_requirements()`` method, which is the recommended place for test
dependencies.

* We use the ``tools.build:skip_test`` configuration (``False`` by default), to tell CMake
whether to build and run the tests or not. A couple of things to bear in mind:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ We have the same header-only library that sums two numbers, but now we have this
package_type = "header-library"

def requirements(self):
self.test_requires("gtest/1.11.0")
self.test_requires("gtest/1.17.0")

def validate(self):
check_min_cppstd(self, 11)
Expand Down Expand Up @@ -199,7 +199,7 @@ We have the same header-only library that sums two numbers, but now we have this

These are the changes introduced in the recipe:

- We are introducing a ``test_require`` to ``gtest/1.11.0``. A ``test_require`` is similar to a regular requirement
- We are introducing a ``test_require`` to ``gtest/1.17.0``. A ``test_require`` is similar to a regular requirement
but it is not propagated to the consumers and cannot conflict.
- ``gtest`` needs at least C++11 to build. So we introduced a ``validate()`` method calling ``check_min_cppstd``.
- As we are building the ``gtest`` examples with CMake, we use the generators ``CMakeToolchain`` and ``CMakeDeps``,
Expand Down
2 changes: 1 addition & 1 deletion tutorial/creating_packages/test_conan_packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ test<reference_commands>` command:
fmt/8.1.1#cd132b054cf999f31bd2fd2424053ddc:ff7a496f48fca9a88dc478962881e015f4a5b98f#1d9bb4c015de50bcb4a338c07229b3bc - Cache
hello/1.0#25e0b5c00ae41ef9fbfbbb1e5ac86e1e:fd7c4113dad406f7d8211b3470c16627b54ff3af#4ff3fd65a1d37b52436bf62ea6eaac04 - Cache
Test requirements
gtest/1.11.0#d136b3379fdb29bdfe31404b916b29e1:656efb9d626073d4ffa0dda2cc8178bc408b1bee#ee8cbd2bf32d1c89e553bdd9d5606127 - Skip
gtest/1.17.0#d136b3379fdb29bdfe31404b916b29e1:656efb9d626073d4ffa0dda2cc8178bc408b1bee#ee8cbd2bf32d1c89e553bdd9d5606127 - Skip

...

Expand Down