Skip to content

Commit

Permalink
Add tests for python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
BUYT-1 committed Aug 13, 2023
1 parent 314cd96 commit 892685e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/bindings-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Python
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
workflow_dispatch:
jobs:
test-python-bindings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
with:
download-pybind: true
- name: Configure CMake
run: >
cmake -B ${{github.workspace}}/build
-DCMAKE_C_COMPILER=gcc-10
-DCMAKE_CXX_COMPILER=g++-10
-DBOOST_ROOT=${{github.workspace}}/lib/boost
-DCMAKE_BUILD_TYPE=Release
-Dgtest_disable_pthreads=OFF
-DASAN=OFF
-DCOMPILE_PYBIND=ON
-DCOMPILE_TESTS=OFF
-DUNPACK_DATASETS=OFF
- name: Build
run: cmake --build ${{github.workspace}}/build --config Release
- name: Test
working-directory: ${{github.workspace}}/build/src/python_bindings
shell: bash
run: python test_bindings.py
7 changes: 7 additions & 0 deletions src/python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ file(GLOB_RECURSE sources "*.h*" "*.cpp*")
pybind11_add_module(${BINDINGS_NAME} ${sources})

target_link_libraries(${BINDINGS_NAME} PRIVATE ${CMAKE_PROJECT_NAME}_lib)

add_custom_command(TARGET ${BINDINGS_NAME}
COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_SOURCE_DIR}/src/python_bindings/test_bindings.py
${CMAKE_SOURCE_DIR}/test_input_data/WDC_satellites.csv
${CMAKE_BINARY_DIR}/src/python_bindings/
)
13 changes: 13 additions & 0 deletions src/python_bindings/test_bindings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from inspect import getmembers, isclass

import desbordante as desb

for name, type_ in getmembers(desb, isclass):
# Assumes no classes inherit from algorithms.
if not (issubclass(type_, desb.FdAlgorithm)
and type_ is not desb.FdAlgorithm):
continue
algorithm = type_()
algorithm.load_data('WDC_satellites.csv', ',', False)
algorithm.execute()
print(name, algorithm.get_fds())

0 comments on commit 892685e

Please sign in to comment.