Skip to content

Commit

Permalink
[misc] Use Ctest for managing C++ unit tests. (#475)
Browse files Browse the repository at this point in the history
* [core] Always regenerate original flexible model at reset to allow manual overwrite of rigid original model.
* [misc] Use Ctest for managing C++ unit tests.

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
  • Loading branch information
duburcqa and Alexis Duburcq authored Dec 15, 2021
1 parent e773be2 commit 95a96d2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ jobs:
run: |
export LD_LIBRARY_PATH="$InstallDir/lib:$InstallDir/lib64:/usr/local/lib"
./build/unit/unit
cd "$RootDir/build"
ctest
cd "$RootDir/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ jobs:

- name: Run unit tests
run: |
./build/unit/unit
cd "$RootDir/build"
ctest
cd "$RootDir/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ jobs:

- name: Run unit tests
run: |
./build/unit/unit
cd "$RootDir/build"
ctest
cd "$RootDir/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ jobs:
- name: Run jiminy unit tests
run: |
"$RootDir/build/unit/unit"
cd "$RootDir/build"
ctest
cd "$RootDir/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ jobs:
run: |
$RootDir = "${env:GITHUB_WORKSPACE}" -replace '\\', '/'
& "$RootDir/build/unit\${env:BUILD_TYPE}/unit.exe"
Set-Location -Path "$RootDir/build"
ctest
Set-Location -Path "$RootDir/unit_py"
python -m unittest discover -v
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ endif()

option(BUILD_TESTING "Build the C++ unit tests." ON)
if(BUILD_TESTING)
include(CTest)
include(GoogleTest)
add_subdirectory(unit)
endif()

Expand Down
7 changes: 7 additions & 0 deletions core/src/robot/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ namespace jiminy

if (isInitialized_)
{
/* Re-generate the true flexible model in case the original rigid
model has been manually modified by the user. */
if (mdlOptions_->dynamics.enableFlexibleModel)
{
generateModelFlexible();
}

// Update the biases added to the dynamics properties of the model
generateModelBiased();
}
Expand Down
9 changes: 6 additions & 3 deletions unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ set(UNIT_TEST_FILES
# Create the unit test executable
add_executable(${PROJECT_NAME} ${UNIT_TEST_FILES})

# Add tests with CTest
gtest_discover_tests(${PROJECT_NAME})

# Add definition of unit test data folder
add_definitions("-DUNIT_TEST_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"")
target_compile_definitions(${PROJECT_NAME} PUBLIC
"-DUNIT_TEST_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\""
)

# Link with Jiminy core library
target_link_libraries(${PROJECT_NAME} ${LIBRARY_NAME}_core)
Expand All @@ -33,5 +38,3 @@ target_link_libraries(${PROJECT_NAME} "${CMAKE_THREAD_LIBS_INIT}")
set_property(TARGET ${PROJECT_NAME} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
)
include(CTest)
enable_testing()

0 comments on commit 95a96d2

Please sign in to comment.