[DO-987] catch recipe (!3)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/3 Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Co-authored-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.team> Co-committed-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.team>
This commit is contained in:
committed by
Denis Patrakeev
parent
bb6197bed7
commit
e3106d807c
5
recipes/catch2/3.x.x/test_package/100-standalone.cpp
Normal file
5
recipes/catch2/3.x.x/test_package/100-standalone.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE( "compiles and runs" ) {
|
||||
REQUIRE( true == !false );
|
||||
}
|
||||
12
recipes/catch2/3.x.x/test_package/200-benchmark.cpp
Normal file
12
recipes/catch2/3.x.x/test_package/200-benchmark.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/benchmark/catch_benchmark.hpp>
|
||||
|
||||
unsigned int Factorial( unsigned int number ) {
|
||||
return number > 1 ? Factorial(number-1)*number : 1;
|
||||
}
|
||||
|
||||
TEST_CASE( "compiles and runs" ) {
|
||||
BENCHMARK("factorial 25"){
|
||||
return Factorial(25);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
CATCH_TEST_CASE( "compiles and runs" ) {
|
||||
CATCH_REQUIRE( true == !false );
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/benchmark/catch_benchmark.hpp>
|
||||
|
||||
unsigned int Factorial( unsigned int number ) {
|
||||
return number > 1 ? Factorial(number-1)*number : 1;
|
||||
}
|
||||
|
||||
CATCH_TEST_CASE( "compiles and runs" ) {
|
||||
CATCH_BENCHMARK("factorial 25"){
|
||||
return Factorial(25);
|
||||
};
|
||||
}
|
||||
16
recipes/catch2/3.x.x/test_package/CMakeLists.txt
Normal file
16
recipes/catch2/3.x.x/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package LANGUAGES CXX)
|
||||
|
||||
find_package(Catch2 REQUIRED CONFIG)
|
||||
|
||||
if(WITH_PREFIX)
|
||||
add_executable(standalone 300-standalone-with-prefix.cpp)
|
||||
add_executable(benchmark 400-benchmark-with-prefix.cpp)
|
||||
else()
|
||||
add_executable(standalone 100-standalone.cpp)
|
||||
add_executable(benchmark 200-benchmark.cpp)
|
||||
endif()
|
||||
target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain)
|
||||
target_compile_features(standalone PRIVATE cxx_std_14)
|
||||
target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain)
|
||||
target_compile_features(benchmark PRIVATE cxx_std_14)
|
||||
31
recipes/catch2/3.x.x/test_package/conanfile.py
Normal file
31
recipes/catch2/3.x.x/test_package/conanfile.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["WITH_PREFIX"] = self.dependencies[self.tested_reference_str].options.with_prefix
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
self.run(os.path.join(self.cpp.build.bindirs[0], "standalone"), env="conanrun")
|
||||
self.run(os.path.join(self.cpp.build.bindirs[0], "benchmark"), env="conanrun")
|
||||
Reference in New Issue
Block a user