Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
eb09af5e
"example/example-numpy-vectorize.py" did not exist on "b47a9de03542df3743f252b935c52e0d8582a77c"
Commit
eb09af5e
authored
Dec 13, 2016
by
Lori A. Burns
Committed by
Wenzel Jakob
Dec 13, 2016
Browse files
test installed pybind
parent
545b4dbc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
110 additions
and
0 deletions
+110
-0
.appveyor.yml
.appveyor.yml
+1
-0
.travis.yml
.travis.yml
+1
-0
tests/CMakeLists.txt
tests/CMakeLists.txt
+48
-0
tests/test_installed_module/CMakeLists.txt
tests/test_installed_module/CMakeLists.txt
+14
-0
tests/test_installed_module/main.cpp
tests/test_installed_module/main.cpp
+10
-0
tests/test_installed_module/test.py
tests/test_installed_module/test.py
+3
-0
tests/test_installed_target/CMakeLists.txt
tests/test_installed_target/CMakeLists.txt
+20
-0
tests/test_installed_target/main.cpp
tests/test_installed_target/main.cpp
+10
-0
tests/test_installed_target/test.py
tests/test_installed_target/test.py
+3
-0
No files found.
.appveyor.yml
View file @
eb09af5e
...
...
@@ -30,3 +30,4 @@ build_script:
-
cmake -A "%CMAKE_ARCH%" -DPYBIND11_WERROR=ON
-
set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
-
cmake --build . --config Release --target pytest -- /v:m /logger:%MSBuildLogger%
-
cmake --build . --config Release --target test_install -- /v:m /logger:%MSBuildLogger%
.travis.yml
View file @
eb09af5e
...
...
@@ -110,5 +110,6 @@ script:
-DPYBIND11_CPP_STANDARD=$CPP
-DPYBIND11_WERROR=ON
-
$SCRIPT_RUN_PREFIX make pytest -j
2
-
$SCRIPT_RUN_PREFIX make test_install
after_script
:
-
if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
tests/CMakeLists.txt
View file @
eb09af5e
...
...
@@ -105,6 +105,54 @@ if(PYBIND11_TEST_OVERRIDE)
COMMAND
${
CMAKE_COMMAND
}
-E echo
"Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect"
)
endif
()
# test use of installation
if
(
PYBIND11_INSTALL
)
# 2.8.12 needed for test_installed_module
# 3.0 needed for interface library for test_installed_target
# 3.1 needed for cmake -E env for testing
if
(
NOT CMAKE_VERSION VERSION_LESS 3.1
)
add_custom_target
(
test_installed_target
COMMAND
${
CMAKE_COMMAND
}
"-DCMAKE_INSTALL_PREFIX=
${
PROJECT_BINARY_DIR
}
/test_install"
-P
"
${
PROJECT_BINARY_DIR
}
/cmake_install.cmake"
COMMAND
${
CMAKE_CTEST_COMMAND
}
--build-and-test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_installed_target"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/test_installed_target"
--build-noclean
--build-generator
${
CMAKE_GENERATOR
}
$<$<BOOL:
${
CMAKE_GENERATOR_PLATFORM
}
>:--build-generator-platform>
${
CMAKE_GENERATOR_PLATFORM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-target check
--build-options
"-DCMAKE_PREFIX_PATH=
${
PROJECT_BINARY_DIR
}
/test_install"
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DPYTHON_EXECUTABLE=
${
PYTHON_EXECUTABLE
}
"
"-DPYBIND11_CPP_STANDARD=
${
PYBIND11_CPP_STANDARD
}
"
)
add_custom_target
(
test_installed_module
COMMAND
${
CMAKE_COMMAND
}
"-DCMAKE_INSTALL_PREFIX=
${
PROJECT_BINARY_DIR
}
/test_install"
-P
"
${
PROJECT_BINARY_DIR
}
/cmake_install.cmake"
COMMAND
${
CMAKE_CTEST_COMMAND
}
--build-and-test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_installed_module"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/test_installed_module"
--build-noclean
--build-generator
${
CMAKE_GENERATOR
}
$<$<BOOL:
${
CMAKE_GENERATOR_PLATFORM
}
>:--build-generator-platform>
${
CMAKE_GENERATOR_PLATFORM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-target check
--build-options
"-DCMAKE_PREFIX_PATH=
${
PROJECT_BINARY_DIR
}
/test_install"
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DPYTHON_EXECUTABLE=
${
PYTHON_EXECUTABLE
}
"
"-DPYBIND11_CPP_STANDARD=
${
PYBIND11_CPP_STANDARD
}
"
)
else
()
add_custom_target
(
test_installed_target
)
add_custom_target
(
test_installed_module
)
endif
()
add_custom_target
(
test_install
)
add_dependencies
(
test_install test_installed_target test_installed_module
)
endif
()
# And another to show the .so size and, if a previous size, compare it:
add_custom_command
(
TARGET pybind11_tests POST_BUILD
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_SOURCE_DIR
}
/tools/libsize.py
...
...
tests/test_installed_module/CMakeLists.txt
0 → 100644
View file @
eb09af5e
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
test_installed_module CXX
)
set
(
CMAKE_MODULE_PATH
""
)
find_package
(
pybind11 CONFIG REQUIRED
)
message
(
STATUS
"Found pybind11:
${
pybind11_INCLUDE_DIRS
}
(found version
${
pybind11_VERSION
}
)"
)
message
(
STATUS
"Found Python:
${
PYTHON_INCLUDE_DIRS
}
(found version
${
PYTHON_VERSION_STRING
}
)"
)
pybind11_add_module
(
test_installed_module SHARED main.cpp
)
add_custom_target
(
check
${
CMAKE_COMMAND
}
-E env PYTHONPATH=$<TARGET_FILE_DIR:test_installed_module>
${
PYTHON_EXECUTABLE
}
${
PROJECT_SOURCE_DIR
}
/test.py
)
tests/test_installed_module/main.cpp
0 → 100644
View file @
eb09af5e
#include <pybind11/pybind11.h>
namespace
py
=
pybind11
;
PYBIND11_PLUGIN
(
test_installed_module
)
{
py
::
module
m
(
"test_installed_module"
);
m
.
def
(
"add"
,
[](
int
i
,
int
j
)
{
return
i
+
j
;
});
return
m
.
ptr
();
}
tests/test_installed_module/test.py
0 → 100644
View file @
eb09af5e
import
test_installed_module
assert
test_installed_module
.
add
(
11
,
22
)
==
33
print
(
'test_installed_module imports, runs, and adds: 11 + 22 = 33'
)
tests/test_installed_target/CMakeLists.txt
0 → 100644
View file @
eb09af5e
cmake_minimum_required
(
VERSION 3.0
)
project
(
test_installed_target CXX
)
set
(
CMAKE_MODULE_PATH
""
)
find_package
(
pybind11 CONFIG REQUIRED
)
message
(
STATUS
"Found pybind11:
${
pybind11_INCLUDE_DIRS
}
(found version
${
pybind11_VERSION
}
)"
)
message
(
STATUS
"Found Python:
${
PYTHON_INCLUDE_DIRS
}
(found version
${
PYTHON_VERSION_STRING
}
)"
)
add_library
(
test_installed_target MODULE main.cpp
)
target_link_libraries
(
test_installed_target PRIVATE pybind11::pybind11
)
# make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib
set_target_properties
(
test_installed_target PROPERTIES PREFIX
"
${
PYTHON_MODULE_PREFIX
}
"
SUFFIX
"
${
PYTHON_MODULE_EXTENSION
}
"
)
add_custom_target
(
check
${
CMAKE_COMMAND
}
-E env PYTHONPATH=$<TARGET_FILE_DIR:test_installed_target>
${
PYTHON_EXECUTABLE
}
${
PROJECT_SOURCE_DIR
}
/test.py
)
tests/test_installed_target/main.cpp
0 → 100644
View file @
eb09af5e
#include <pybind11/pybind11.h>
namespace
py
=
pybind11
;
PYBIND11_PLUGIN
(
test_installed_target
)
{
py
::
module
m
(
"test_installed_target"
);
m
.
def
(
"add"
,
[](
int
i
,
int
j
)
{
return
i
+
j
;
});
return
m
.
ptr
();
}
tests/test_installed_target/test.py
0 → 100644
View file @
eb09af5e
import
test_installed_target
assert
test_installed_target
.
add
(
1
,
2
)
==
3
print
(
'test_installed_target imports, runs, and adds: 1 + 2 = 3'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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