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

catch2 (2.x.x): support conan v2 #13794

Merged
merged 19 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions recipes/catch2/2.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def configure(self):
self.options.rm_safe("with_benchmark")

def package_id(self):
if not self.options.with_main:
if not self.info.options.with_main:
paulharris marked this conversation as resolved.
Show resolved Hide resolved
self.info.clear()

def layout(self):
Expand All @@ -55,7 +55,7 @@ def layout(self):
def validate(self):
if Version(self.version) < "2.13.1" and self.settings.arch == "armv8":
raise ConanInvalidConfiguration("ARMv8 is not supported by versions < 2.13.1+")
if self.options.with_main and Version(self.version) < "2.13.4":
if self.info.options.get_safe("with_main") and Version(self.version) < "2.13.4":
raise ConanInvalidConfiguration("Option with_main not supported by versions < 2.13.4")

def source(self):
Expand Down
10 changes: 10 additions & 0 deletions recipes/catch2/2.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout
import os
import yaml

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
Expand All @@ -11,6 +12,10 @@ class TestPackageConan(ConanFile):

_tests_todo = []

@property
def _todos_filename(self):
return os.path.join(self.recipe_folder, self.folders.generators, "catch2_test_to_do.yml")

def requirements(self):
self.requires(self.tested_reference_str)

Expand All @@ -29,6 +34,9 @@ def generate(self):
if not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark:
self._tests_todo.append("benchmark")

with open(self._todos_filename, "w", encoding="utf-8") as file:
yaml.dump(self._tests_todo, file)

def layout(self):
cmake_layout(self)

Expand All @@ -38,6 +46,8 @@ def build(self):
cmake.build()

def test(self):
with open(self._todos_filename, "r", encoding="utf-8") as file:
self._tests_todo = yaml.safe_load(file)
if can_run(self):
for test_name in self._tests_todo:
self.run(os.path.join(self.cpp.build.bindirs[0], test_name), env="conanrun")