Commit daa63077 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Fix test package

parent 7dafdf4e
Pipeline #7922 failed with stages
in 1 minute and 26 seconds
project(PackageTest CXX)
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.8)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(PythonLibs REQUIRED)
add_library(test_package MODULE test_package.cpp)
target_include_directories(test_package PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(test_package PRIVATE CONAN_PKG::pybind11 ${PYTHON_LIBRARIES})
target_compile_features(test_package PRIVATE cxx_std_17)
# set_target_properties(test_package PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
# SUFFIX "${PYTHON_MODULE_EXTENSION}")
find_package(pybind11 REQUIRED)
enable_testing()
add_test(NAME test_package_py
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
COMMAND $(PYTHON_PREFIX) test_package.py)
\ No newline at end of file
pybind11_add_module(test_package MODULE test_package.cpp)
import os
import sys
from conans import ConanFile, CMake, tools
class BenchmarkTestConan(ConanFile):
class Pybind11TestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
......@@ -20,5 +21,8 @@ class BenchmarkTestConan(ConanFile):
def test(self):
if not tools.cross_building(self.settings):
os.chdir("lib")
self.run("python3 ..%s..%s..%stest_package.py" %
(os.sep, os.sep, os.sep))
sys.path.append(".")
import test_package
assert test_package.add(1, 2) == 3
assert test_package.subtract(2, 1) == 1
import unittest
class TestPackage(unittest.TestCase):
def test_add(self):
import test_package
print(test_package.__doc__)
self.assertEqual(test_package.add(1, 2), 3)
def test_substract(self):
import test_package
self.assertEqual(test_package.substract(2, 1), 1)
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment