Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/BuildTestInstall/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ runs:
working-directory: ${{github.workspace}}/test/pytest
run: pytest

- name: gtest
- name: ctest
shell: ${{inputs.shell}}
working-directory: ${{github.workspace}}/build
run: ctest
run: ctest -R BinaryLoggerTestSuite -R LoggerTestSuite

- name: Install
shell: ${{inputs.shell}}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ __pycache__/
*.so

*.tar
Testing/
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ project("NumCpp"
LANGUAGES CXX
)

enable_testing()

message(STATUS "Building ${PROJECT_NAME} version ${VERSION_STRING}")

if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -30,10 +28,12 @@ message(STATUS "Compiling with C++ standard: ${CMAKE_CXX_STANDARD}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # works

option(BUILD_ALL "Build All targets" OFF)
option(BUILD_ALL_NON_PYTHON "Build All targets except the python bindings for pytest" OFF)
option(BUILD_DOCS "Build the doxygen documentation" OFF)
option(BUILD_TESTS "Build the unit tests" OFF)
option(BUILD_MULTIPLE_TEST "Build the multiple translation unit test" OFF)
option(BUILD_CPPCHECK_TEST "Build the cppcheck test" OFF)
option(BUILD_GTEST "Build the gtest tests" OFF)
option(BUILD_EXAMPLE_ALL "Build all of the examples" OFF)
option(BUILD_EXAMPLE_GAUSS_NEWTON_NLLS "Build the Gauss-Newton NLLS example" OFF)
option(BUILD_EXAMPLE_INTERFACE_WITH_EIGEN "Build the Interface with Eigen example" OFF)
Expand All @@ -44,10 +44,15 @@ option(NUMCPP_NO_USE_BOOST "Don't use the boost libraries" OFF)
option(NUMCPP_USE_MULTITHREAD "Enable multithreading" OFF)

if(BUILD_ALL)
set(BUILD_DOCS ON)
set(BUILD_ALL_NON_PYTHON ON)
set(BUILD_TESTS ON)
endif()

if(BUILD_ALL_NON_PYTHON)
set(BUILD_DOCS ON)
set(BUILD_MULTIPLE_TEST ON)
set(BUILD_CPPCHECK_TEST ON)
set(BUILD_GTEST ON)
set(BUILD_EXAMPLE_ALL ON)
endif()

Expand Down Expand Up @@ -134,6 +139,7 @@ get_filename_component(NUMCPP_INCLUDES ./include ABSOLUTE)
set(OUTPUT_BINARY_DIR ${PROJECT_SOURCE_DIR}/bin/$<0:>)

if (BUILD_TESTS OR BUILD_MULTIPLE_TEST OR BUILD_CPPCHECK_TEST)
enable_testing()
add_subdirectory(test)
endif()

Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ if(BUILD_CPPCHECK_TEST)
message(STATUS "Configuring CPPCheck Test")
add_subdirectory(cppcheck)
endif()

if(BUILD_GTEST)
message(STATUS "Configuring GTest")
add_subdirectory(gtest)
endif()
9 changes: 9 additions & 0 deletions test/cppcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ add_executable(${TARGET_NAME}
CppCheck.cpp
)

set_target_properties(${TARGET_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
)

target_include_directories(${TARGET_NAME} PRIVATE
${NUMCPP_INCLUDES}
)

target_link_libraries(${TARGET_NAME} PRIVATE
${ALL_INTERFACE_TARGET}
)

add_test(NAME ${TARGET_NAME}
COMMAND ${TARGET_NAME}
)
4 changes: 4 additions & 0 deletions test/cppcheck/CppCheck.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "NumCpp.hpp"

#include <iostream>

int main()
{
std::cout << "Dummy file to include all headers for CppCheck\n";

return 0;
}
9 changes: 7 additions & 2 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

set(TARGET_NAME NumCpp_tests)
set(TARGET_NAME LoggerTests)

add_executable(${TARGET_NAME}
test_BinaryLogger.cpp
test_Logger.cpp
)

set_target_properties(${TARGET_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINARY_DIR}
)

target_include_directories(${TARGET_NAME} PRIVATE
${NUMCPP_INCLUDES}
)
Expand All @@ -18,4 +23,4 @@ target_link_libraries(${TARGET_NAME} PRIVATE
)

include(GoogleTest)
gtest_discover_tests(${TARGET_NAME})
gtest_discover_tests(${TARGET_NAME})
4 changes: 4 additions & 0 deletions test/multiple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
target_link_libraries(${TARGET_NAME} PRIVATE
${ALL_INTERFACE_TARGET}
)

add_test(NAME ${TARGET_NAME}
COMMAND ${TARGET_NAME}
)
11 changes: 11 additions & 0 deletions test/pytest/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,19 @@ find_package(Python 3.11 REQUIRED
Development.Module
)

if(UNIX)
execute_process(
COMMAND
python3-config --ldflags
OUTPUT_VARIABLE
PYTHON_LD_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()

target_link_libraries(${TARGET_NAME} PRIVATE
Python::Module
${PYTHON_LD_FLAGS}
${ALL_INTERFACE_TARGET}
)

Expand Down
28 changes: 14 additions & 14 deletions test/pytest/src/pybind11/pybind11/buffer_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ struct buffer_info {
template <typename T>
buffer_info(const T *ptr, ssize_t size, bool readonly = true)
: buffer_info(
const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}

explicit buffer_info(Py_buffer *view, bool ownview = true)
: buffer_info(
view->buf,
view->itemsize,
view->format,
view->ndim,
{view->shape, view->shape + view->ndim},
/* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
* ignore this flag and return a view with NULL strides.
* When strides are NULL, build them manually. */
view->strides
? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
: detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
(view->readonly != 0)) {
view->buf,
view->itemsize,
view->format,
view->ndim,
{view->shape, view->shape + view->ndim},
/* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
* ignore this flag and return a view with NULL strides.
* When strides are NULL, build them manually. */
view->strides
? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
: detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
(view->readonly != 0)) {
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
this->m_view = view;
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
Expand Down Expand Up @@ -176,7 +176,7 @@ struct buffer_info {
detail::any_container<ssize_t> &&strides_in,
bool readonly)
: buffer_info(
ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}

Py_buffer *m_view = nullptr;
bool ownview = false;
Expand Down
Loading
Loading