Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Use Ctest for managing C++ unit tests. #475

Merged
merged 2 commits into from
Dec 15, 2021
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
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()