From 413b3e0c6b3cdbcbc5fc8d2a5c4b6b325d8dbe9a Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 30 Mar 2021 13:22:08 +0200 Subject: [PATCH 1/3] wip --- howtos/header_only.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/howtos/header_only.rst b/howtos/header_only.rst index bf515a9d943..d61eb6dcecb 100644 --- a/howtos/header_only.rst +++ b/howtos/header_only.rst @@ -81,14 +81,9 @@ If you want to run the library unit test while packaging, you would need this re If you are :ref:`cross-building ` your **library** or **app** you'll probably need to skip the **unit tests** because your target binary cannot be executed in current building host. - To do it you can use :ref:`tools_get_env` in combination with - :ref:`env_vars_conan_run_tests` environment variable, defined as **False** - in profile for cross-building and replace ``cmake.test()`` with: - - .. code-block:: python - - if tools.get_env("CONAN_RUN_TESTS", True): - cmake.test() + To do it you can use :ref:`env_vars_conan_run_tests` environment variable, defined as **False** + in profile for cross-building in the call to ``cmake.test()`` this variable will be evaluated and + the tests will not run. Which will use a ``CMakeLists.txt`` file in the root folder: From cbd9cfebbe0db0ac11af967a725401794022ab1b Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 30 Mar 2021 13:24:22 +0200 Subject: [PATCH 2/3] wip --- reference/env_vars.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reference/env_vars.rst b/reference/env_vars.rst index 0e0d094b26d..71de2bb63d8 100644 --- a/reference/env_vars.rst +++ b/reference/env_vars.rst @@ -477,7 +477,7 @@ or declared in command line when invoking :command:`conan install` to reduce the See how to retrieve the value with :ref:`tools.get_env() ` and check a use case with :ref:`a header only with unit tests recipe ` while cross building. -See example of build method in ``conanfile.py`` to enable/disable running tests with CMake: +This variable is evaluated inside the build helper call to ``test()`` and will not run the tests if set to ``False``. .. code-block:: python @@ -491,8 +491,7 @@ See example of build method in ``conanfile.py`` to enable/disable running tests cmake = CMake(self) cmake.configure() cmake.build() - if tools.get_env("CONAN_RUN_TESTS", True): - cmake.test() + cmake.test() .. _env_vars_conan_skip_vs_project_upgrade: From e0acb79c4b49403e170e734bc6ff6a1b4ae59232 Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 30 Mar 2021 13:27:29 +0200 Subject: [PATCH 3/3] update bh docs --- reference/build_helpers/cmake.rst | 4 +++- reference/build_helpers/meson.rst | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/reference/build_helpers/cmake.rst b/reference/build_helpers/cmake.rst index 01c6bcb5a75..de82e0ba824 100644 --- a/reference/build_helpers/cmake.rst +++ b/reference/build_helpers/cmake.rst @@ -335,7 +335,9 @@ test() def test(args=None, build_dir=None, target=None, output_on_failure=False) -Build `CMake` test target (could be RUN_TESTS in multi-config projects or ``test`` in single-config projects), which usually means building and running unit tests +Build `CMake` test target (could be RUN_TESTS in multi-config projects or ``test`` in single-config +projects), which usually means building and running unit tests. When this function is called +:ref:`env_vars_conan_run_tests` will be evaluated to check if tests should run. Parameters: - **args** (Optional, Defaulted to ``None``): A list of additional arguments to be passed to the ``cmake`` command. Each argument will be escaped according to the current shell. No extra arguments will be added if ``args=None``. diff --git a/reference/build_helpers/meson.rst b/reference/build_helpers/meson.rst index 2007c0e3469..343498c1f27 100644 --- a/reference/build_helpers/meson.rst +++ b/reference/build_helpers/meson.rst @@ -89,7 +89,8 @@ test() def test(args=None, build_dir=None, target=None) -Executes ninja test target, which usually means building and running unit tests. +Executes ninja test target, which usually means building and running unit tests. When this function +is called :ref:`env_vars_conan_run_tests` will be evaluated to check if tests should run. Parameters: - **args** (Optional, Defaulted to ``None``): A list of additional arguments to be passed to the ``ninja`` command. Each argument will be escaped