Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Olena
conan-pybind11
Commits
daa63077
Commit
daa63077
authored
Apr 04, 2019
by
Michaël Roynard
Browse files
Fix test package
parent
7dafdf4e
Pipeline
#7922
failed with stages
in 1 minute and 26 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test_package/CMakeLists.txt
View file @
daa63077
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
)
test_package/conanfile.py
View file @
daa63077
import
os
import
sys
from
conans
import
ConanFile
,
CMake
,
tools
class
Benchmark
TestConan
(
ConanFile
):
class
Pybind11
TestConan
(
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
test_package/test_package.py
deleted
100644 → 0
View file @
7dafdf4e
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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment