Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test other generators: run several tests in test_*/conanfile.py #8389

Merged
merged 24 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f3e8908
[poc] Test other generators: run several tests in test_*/conanfile.py
jgsogo Dec 10, 2021
03a4c3b
use new pattern to access info from dependencies
jgsogo Dec 13, 2021
7c1da8d
use rel path
jgsogo Dec 13, 2021
9ac268a
fix import (1.43.1)
jgsogo Dec 21, 2021
6367b7a
Update recipes/fmt/all/test_package/CMakeLists.txt
jgsogo Dec 30, 2021
90fe826
VS output path for CMakeDeps uses configuration type
jgsogo Dec 30, 2021
952941c
Merge branch 'multiple-testing' of github.com:jgsogo/conan-center-ind…
jgsogo Dec 30, 2021
a883211
make it a string
jgsogo Dec 30, 2021
29ce22c
Merge branch 'master' into multiple-testing
jgsogo Jan 12, 2022
e6d6794
force output directory
jgsogo Jan 12, 2022
6281ae1
force it for the configuration name \o/
jgsogo Jan 12, 2022
a27e7ee
following team feedback, this should be the way to go
jgsogo Jan 12, 2022
31b9e5a
use cmake_layout explicitly
jgsogo Jan 12, 2022
251189c
we can delegate the path to the source to the layout
jgsogo Jan 12, 2022
78eff63
Update recipes/fmt/all/test_cmakedeps/conanfile.py
jgsogo Feb 5, 2022
0a3d449
Merge branch 'master' into multiple-testing
jgsogo Feb 5, 2022
e218ce7
touch
jgsogo Feb 5, 2022
bd5b5c1
Merge branch 'multiple-testing' of github.com:jgsogo/conan-center-ind…
jgsogo Feb 5, 2022
20100d5
touch
jgsogo Feb 5, 2022
8a776c2
revert change
jgsogo Feb 5, 2022
33dc9fc
revert back, explained in PR review
jgsogo Feb 5, 2022
7d887a4
Update recipes/fmt/all/test_cmakedeps/conanfile.py
jgsogo Feb 12, 2022
5aa4c58
Merge branch 'master' into multiple-testing
jgsogo Feb 14, 2022
18da51d
touch
jgsogo Feb 14, 2022
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
25 changes: 25 additions & 0 deletions recipes/fmt/all/test_cmakedeps/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
from conans import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
from conan import tools

jgsogo marked this conversation as resolved.
Show resolved Hide resolved

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"

def generate(self):
tc = CMakeToolchain(self)
tc.variables["FMT_HEADER_ONLY"] = self.options["fmt"].header_only
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()

def build(self):
cwd = os.path.dirname(__file__)
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(cwd, "..", "test_package"))
cmake.build()

def test(self):
if not tools.cross_building.cross_building(self):
self.run("test_package", run_environment=True)
self.run("test_ranges", run_environment=True)
6 changes: 4 additions & 2 deletions recipes/fmt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.1.2)
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because the same CMakeLists.txt file is used from the test_cmakedeps/conanfile.py and there we are not adding the cmake generator.

IMO, it is important to reuse as much as possible the same project files.

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
endif()

find_package(fmt REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion recipes/fmt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def build(self):
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
self.run(os.path.join("bin","test_package"), run_environment=True)
self.run(os.path.join("bin","test_ranges"), run_environment=True)