Merge pull request #220 from dean0x7d/fixes
A few smaller fixes and a test output improvement
diff --git a/.appveyor.yml b/.appveyor.yml
index 5e283af..80e02f4 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -19,8 +19,6 @@
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 b0d8a0e..3f9cb50 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,19 +23,19 @@
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 -U pip wheel
- 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 aaa97e8..7d2c991 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,7 @@
if (PYBIND11_TEST)
enable_testing()
add_subdirectory(example)
+ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> DEPENDS example)
endif()
if (PYBIND11_INSTALL)
diff --git a/example/example2.cpp b/example/example2.cpp
index 9b91baa..4b15823 100644
--- a/example/example2.cpp
+++ b/example/example2.cpp
@@ -154,7 +154,7 @@
.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")
diff --git a/example/issues.cpp b/example/issues.cpp
index dfe20ff..d75da1c 100644
--- a/example/issues.cpp
+++ b/example/issues.cpp
@@ -135,7 +135,7 @@
try {
py::class_<Placeholder>(m2, "Placeholder");
throw std::logic_error("Expected an exception!");
- } catch (std::runtime_error &e) {
+ } catch (std::runtime_error &) {
/* All good */
}
}
diff --git a/example/run_test.py b/example/run_test.py
index d0967c6..70ce4a6 100755
--- a/example/run_test.py
+++ b/example/run_test.py
@@ -2,6 +2,7 @@
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 @@
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 @@
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)
diff --git a/include/pybind11/descr.h b/include/pybind11/descr.h
index 1b65f68..6c1d864 100644
--- a/include/pybind11/descr.h
+++ b/include/pybind11/descr.h
@@ -139,7 +139,7 @@
const T *it = ptr;
while (*it++ != (T) 0)
;
- return it - ptr;
+ return static_cast<size_t>(it - ptr);
}
const std::type_info **m_types = nullptr;