diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 46b15555e..e406f1f61 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f67bf008c..e9a36d8d8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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 diff --git a/.github/workflows/manylinux.yml b/.github/workflows/manylinux.yml index 3626e8a76..9db5d9d01 100644 --- a/.github/workflows/manylinux.yml +++ b/.github/workflows/manylinux.yml @@ -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 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c1faa8e3d..a39356a12 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -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 diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 227a1dd4c..0d7444101 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 22bf8dda3..42a68079a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/core/src/robot/Model.cc b/core/src/robot/Model.cc index e03e61a89..98001222a 100644 --- a/core/src/robot/Model.cc +++ b/core/src/robot/Model.cc @@ -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(); } diff --git a/unit/CMakeLists.txt b/unit/CMakeLists.txt index 207e75fd7..cbfc275ea 100755 --- a/unit/CMakeLists.txt +++ b/unit/CMakeLists.txt @@ -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) @@ -33,5 +38,3 @@ target_link_libraries(${PROJECT_NAME} "${CMAKE_THREAD_LIBS_INIT}") set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL" ) -include(CTest) -enable_testing()