From f2b36c2ed2d477607851ddca6c0b136791031669 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Wed, 1 Jun 2016 23:03:10 +0200 Subject: [PATCH 1/5] Fix a couple of warnings - Conversion warning on clang: 'long' to 'size_t' - Unused variable warning on MSVC --- example/issues.cpp | 2 +- include/pybind11/descr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/issues.cpp b/example/issues.cpp index dfe20fff8..d75da1cef 100644 --- a/example/issues.cpp +++ b/example/issues.cpp @@ -135,7 +135,7 @@ void init_issues(py::module &m) { try { py::class_(m2, "Placeholder"); throw std::logic_error("Expected an exception!"); - } catch (std::runtime_error &e) { + } catch (std::runtime_error &) { /* All good */ } } diff --git a/include/pybind11/descr.h b/include/pybind11/descr.h index 1b65f68c8..6c1d86432 100644 --- a/include/pybind11/descr.h +++ b/include/pybind11/descr.h @@ -139,7 +139,7 @@ protected: const T *it = ptr; while (*it++ != (T) 0) ; - return it - ptr; + return static_cast(it - ptr); } const std::type_info **m_types = nullptr; From 4337a5d86a7563cbb4a87eeb756f29bcdf391911 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Wed, 1 Jun 2016 23:11:35 +0200 Subject: [PATCH 2/5] Fix typo which caused the C++ set test to be skipped It used to pass anyway because the expected output was identical to the Python set. --- example/example2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/example2.cpp b/example/example2.cpp index 9b91baaad..4b15823f2 100644 --- a/example/example2.cpp +++ b/example/example2.cpp @@ -154,7 +154,7 @@ void init_ex2(py::module &m) { .def("get_list", &Example2::get_list, "Return a Python list") .def("get_list_2", &Example2::get_list_2, "Return a C++ list") .def("get_set", &Example2::get_set, "Return a Python set") - .def("get_set2", &Example2::get_set, "Return a C++ set") + .def("get_set2", &Example2::get_set_2, "Return a C++ set") .def("get_array", &Example2::get_array, "Return a C++ array") .def("print_dict", &Example2::print_dict, "Print entries of a Python dictionary") .def("print_dict_2", &Example2::print_dict_2, "Print entries of a C++ dictionary") From 1fe59010629cbbfd6ab92de0d34fa091539cca09 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Wed, 1 Jun 2016 23:16:13 +0200 Subject: [PATCH 3/5] Add a more informative diff output for failed tests --- example/run_test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/example/run_test.py b/example/run_test.py index d0967c6e2..70ce4a6c0 100755 --- a/example/run_test.py +++ b/example/run_test.py @@ -2,6 +2,7 @@ import sys import os import re import subprocess +import difflib remove_unicode_marker = re.compile(r'u(\'[^\']*\')') remove_long_marker = re.compile(r'([0-9])L') @@ -36,11 +37,7 @@ def sanitize(lines): line = "" lines[i] = line - lines = '\n'.join(sorted([l for l in lines if l != ""])) - - print('==================') - print(lines) - return lines + return '\n'.join(sorted([l for l in lines if l != ""])) path = os.path.dirname(__file__) if path != '': @@ -69,4 +66,8 @@ elif output == reference: exit(0) else: print('Test "%s" FAILED!' % name) + print('--- output') + print('+++ reference') + print(''.join(difflib.ndiff(output.splitlines(keepends=True), + reference.splitlines(keepends=True)))) exit(-1) From 52ae7b1d33c44ea5340778ff015e5cb7877b7a66 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Wed, 1 Jun 2016 23:28:44 +0200 Subject: [PATCH 4/5] Add 'check' target which both builds and tests --- .appveyor.yml | 6 ++---- .travis.yml | 11 +++++------ CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 5e283af1e..80e02f4f4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,8 +19,6 @@ install: build_script: - echo Running cmake... - cd c:\projects\pybind11 - - cmake -G "%CMAKE_PLATFORM%" -DPYTHON_INCLUDE_DIR:PATH=%PYTHON_DIR%/include -DPYTHON_LIBRARY:FILEPATH=%PYTHON_DIR%/libs/python34.lib -DPYTHON_EXECUTABLE:FILEPATH=%PYTHON_DIR%/python.exe + - cmake -G "%CMAKE_PLATFORM%" -DPYTHON_EXECUTABLE:FILEPATH=%PYTHON_DIR%/python.exe - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - set MSBuildOptions=/v:m /p:Configuration=%Configuration% /logger:%MSBuildLogger% - - msbuild %MSBuildOptions% pybind11.sln - - ctest -C %Configuration% + - cmake --build . --config %Configuration% --target check -- /v:m /logger:%MSBuildLogger% diff --git a/.travis.yml b/.travis.yml index b0d8a0e98..18177a2aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,19 +23,18 @@ matrix: include: - os: linux compiler: gcc-4.8 - script: + install: - pyvenv-3.5 venv - - cmake -DPYBIND11_PYTHON_VERSION=3.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON_EXECUTABLE:FILEPATH=`pwd`/venv/bin/python3.5 -DCMAKE_CXX_COMPILER=g++-4.8 - - make -j 2 - source venv/bin/activate - pip install numpy - - CTEST_OUTPUT_ON_FAILURE=TRUE make test + script: + - CXX=g++-4.8 cmake -DPYBIND11_PYTHON_VERSION=3.5 + - CTEST_OUTPUT_ON_FAILURE=TRUE make check -j 2 - os: osx compiler: clang script: - cmake -DPYBIND11_PYTHON_VERSION=2.7 - - make -j 2 - - CTEST_OUTPUT_ON_FAILURE=TRUE make test + - CTEST_OUTPUT_ON_FAILURE=TRUE make check -j 2 #- os: linux #compiler: gcc-4.8 #script: diff --git a/CMakeLists.txt b/CMakeLists.txt index aaa97e8a5..7d2c991ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,7 @@ endfunction() if (PYBIND11_TEST) enable_testing() add_subdirectory(example) + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $ DEPENDS example) endif() if (PYBIND11_INSTALL) From ba0a0c063faf313a46a186970b1001a90fc6446e Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Thu, 2 Jun 2016 08:49:41 +0200 Subject: [PATCH 5/5] Install numpy from manylinux binary wheel on Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 18177a2aa..3f9cb501c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: install: - pyvenv-3.5 venv - source venv/bin/activate + - pip install -U pip wheel - pip install numpy script: - CXX=g++-4.8 cmake -DPYBIND11_PYTHON_VERSION=3.5