From dfda9857131befe0619e3250ca559416abf0a1f6 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Thu, 25 May 2023 12:21:44 -0700 Subject: [PATCH] (#17705) docs: remove mention of the migration test_v1_package * Delete docs/package_templates/autotools_package/all/test_v1_package directory * Delete docs/package_templates/cmake_package/all/test_v1_package directory * Delete docs/package_templates/header_only/all/test_v1_package directory * Delete docs/package_templates/meson_package/all/test_v1_package directory * Delete docs/package_templates/msbuild_package/all/test_v1_package directory * Delete docs/package_templates/prebuilt_tool_package/all/test_v1_package directory * Update test_packages.md * Update error_knowledge_base.md --- docs/adding_packages/test_packages.md | 22 ++++++++---------- docs/error_knowledge_base.md | 4 ---- .../all/test_v1_package/CMakeLists.txt | 11 --------- .../all/test_v1_package/conanfile.py | 19 --------------- .../all/test_v1_package/CMakeLists.txt | 8 ------- .../all/test_v1_package/conanfile.py | 19 --------------- .../all/test_v1_package/CMakeLists.txt | 9 -------- .../all/test_v1_package/conanfile.py | 19 --------------- .../all/test_v1_package/conanfile.py | 23 ------------------- .../all/test_v1_package/CMakeLists.txt | 12 ---------- .../all/test_v1_package/conanfile.py | 19 --------------- .../all/test_v1_package/conanfile.py | 13 ----------- 12 files changed, 9 insertions(+), 169 deletions(-) delete mode 100644 docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt delete mode 100644 docs/package_templates/autotools_package/all/test_v1_package/conanfile.py delete mode 100644 docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt delete mode 100644 docs/package_templates/cmake_package/all/test_v1_package/conanfile.py delete mode 100644 docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt delete mode 100644 docs/package_templates/header_only/all/test_v1_package/conanfile.py delete mode 100644 docs/package_templates/meson_package/all/test_v1_package/conanfile.py delete mode 100644 docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt delete mode 100644 docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py delete mode 100644 docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py diff --git a/docs/adding_packages/test_packages.md b/docs/adding_packages/test_packages.md index 5870221fbc..acca57f456 100644 --- a/docs/adding_packages/test_packages.md +++ b/docs/adding_packages/test_packages.md @@ -8,19 +8,19 @@ themselves. It's possible to have ConanCenter run `conan test` on more then one ## Contents - * [Files and Structure](#files-and-structure) - * [CMake targets](#cmake-targets) - * [Testing more generators with `test_`](#testing-more-generators-with-test_something) - * [Testing CMake variables from FindModules](#testing-cmake-variables-from-findmodules) - * [How it works](#how-it-works) - * [Minimalist Source Code](#minimalist-source-code) + * [Files and Structure](#files-and-structure) + * [CMake targets](#cmake-targets) + * [Testing more generators with `test_`](#testing-more-generators-with-test_something) + * [Testing CMake variables from FindModules](#testing-cmake-variables-from-findmodules) + * [How it works](#how-it-works) + * [Minimalist Source Code](#minimalist-source-code) ### Files and Structure See the [recipe files and structures](README.md#recipe-files-structure) for a visual. All ConanCenterIndex recipe should have a two [test_folders](https://docs.conan.io/1/reference/commands/creator/create.html?highlight=test_folder) -One for the current CMake generator in `test_package/` and on for the deprecated generators in `test_v1_package/`. +One for the current CMake generator in `test_package/`. Please refer to the [Package Templates](../package_templates/) for the current practices about which files and what their content should be. @@ -39,11 +39,7 @@ target_link_libraries(test_ranges PRIVATE fmt::fmt) Refer to the [package template](https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt) for more examples. -> **Notes** It's still important to test targets provided by `cmake_find_package[_multi]` generators. -> It should help in the migration (and compatibility) with Conan v2. See [v1 test package template](https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt) for details. -> You can see read [this conversation](https://github.com/conan-io/conan-center-index/issues/12888#issuecomment-1290817799) for more context. - -In ConanCenter we try to accurately represent the names of the targets and the information provided by CMake's modules and config files that some libraries +In ConanCenterIndex, we try to accurately represent the names of the targets and the information provided by CMake's modules and config files that some libraries provide. If CMake or the library itself don't enforce any target name, the default ones provided by Conan should be recommended. The minimal project in the `test_package` folder should serve as an example of the best way to consume the package, and targets are preferred over raw variables. @@ -60,7 +56,7 @@ of them together in the testing logs. Sometimes it is useful to test the package using different build systems (CMake, Autotools,...). Instead of adding complex logic to one `test_package/conanfile.py` file, it is better to add another `test_/conanfile.py` file with a minimal example for that build system. That way the examples will be short and easy to understand and maintain. In some other situations it could be useful to test different Conan generators -(`cmake_find_package`, `CMakeDeps`,...) using different folders and `conanfile.py` files. +(e.g. `CMakeDeps`) using different folders and `conanfile.py` files. When using more than one `test_` folder, create a different project for each of them to keep the content of the `conanfile.py` and the project files as simple as possible, without the need of extra logic to handle different scenarios. diff --git a/docs/error_knowledge_base.md b/docs/error_knowledge_base.md index 2cd397492d..415d9fd2e9 100644 --- a/docs/error_knowledge_base.md +++ b/docs/error_knowledge_base.md @@ -476,10 +476,6 @@ def package_info(self): Pylint is executed by default over all `conanfile.py` files in ConanCenterIndex and it should not be skipped. It's an important tool which helps us keep a standard level of acceptance. Otherwise, it would be incredibly hard to review all recipes and keep them to the same level of standards. -#### **#KB-H073: "TEST V1 PACKAGE FOLDER"** - -The legacy content in test_package should not be removed. Instead, rename that folder to `test_v1_package` and create a new `test_package` folder following the [file structure](adding_packages/README.md#recipe-files-structure) related to Conan v2 and v1 compatibility. Also, you can obtain good examples of Conan v2 test packages from the [template packages](package_templates/README.md) folder. - #### **#KB-H075: "REQUIREMENT OVERRIDE PARAMETER"** The [self.requires()](https://docs.conan.io/1/reference/conanfile/methods.html#requirements) allows to override a dependency version, forcing to use that version imposed by the recipe only. As a side-effect, dependencies can use different versions of the same project at the same package, which may cause unpredicted errors, like ABI incompatibility. For that reason, the `override` parameter is forbidden and should not be used. Instead, all dependencies should align their package versions, even when it's necessary to open more pull requests to update dependency versions. diff --git a/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 206d47b726..0000000000 --- a/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(test_package LANGUAGES C) # if the project is pure C -# project(test_package LANGUAGES CXX) # if the project uses c++ - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(package REQUIRED CONFIG) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py b/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py deleted file mode 100644 index c492184eec..0000000000 --- a/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,19 +0,0 @@ -from conans import ConanFile, CMake -from conan.tools.build import cross_building -import os - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 91630d79f4..0000000000 --- a/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py b/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py deleted file mode 100644 index c492184eec..0000000000 --- a/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,19 +0,0 @@ -from conans import ConanFile, CMake -from conan.tools.build import cross_building -import os - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt b/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 7738c036b5..0000000000 --- a/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(test_package LANGUAGES C) # if the project is pure C -project(test_package LANGUAGES CXX) # if the project uses c++ - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/header_only/all/test_v1_package/conanfile.py b/docs/package_templates/header_only/all/test_v1_package/conanfile.py deleted file mode 100644 index c492184eec..0000000000 --- a/docs/package_templates/header_only/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,19 +0,0 @@ -from conans import ConanFile, CMake -from conan.tools.build import cross_building -import os - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/meson_package/all/test_v1_package/conanfile.py b/docs/package_templates/meson_package/all/test_v1_package/conanfile.py deleted file mode 100644 index c5b0743138..0000000000 --- a/docs/package_templates/meson_package/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,23 +0,0 @@ -from conans import ConanFile, Meson -from conan.tools.build import cross_building -import os - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "pkg_config" - - def build_requirements(self): - self.build_requires("meson/0.63.3") - self.build_requires("pkgconf/1.9.3") - - def build(self): - meson = Meson(self) - meson.configure(build_folder="bin", source_folder="../test_package") - meson.build() - - def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 510461758a..0000000000 --- a/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(test_package C) # if the project is pure C -project(test_package CXX) # if the project uses c++ - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(package REQUIRED CONFIG) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py b/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py deleted file mode 100644 index c492184eec..0000000000 --- a/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,19 +0,0 @@ -from conans import ConanFile, CMake -from conan.tools.build import cross_building -import os - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py deleted file mode 100644 index 36fd085b2d..0000000000 --- a/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,13 +0,0 @@ -from conans import ConanFile -from conan.tools.build import can_run - - -# legacy validation with Conan 1.x -class TestPackageV1Conan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - - def test(self): - if can_run(self): - # self.run checks the command exit code - # the tool must be available on PATH, which is configured by self.env_info.PATH - self.run("tool --version", run_environment=True)