Skip to content

Commit

Permalink
Port unit tests to catch v3 (#185)
Browse files Browse the repository at this point in the history
* Port unit tests to catch v3

It fixes #183
  • Loading branch information
Nicogene authored Sep 6, 2023
1 parent be84ef5 commit 6f17680
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 70 deletions.
61 changes: 1 addition & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,12 @@ jobs:
strategy:
matrix:
build_type: [Release, Debug]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
yarp: [true, false]

steps:
- uses: actions/checkout@master

- name: Set up environment variables [Windows]
if: matrix.os == 'windows-latest'
shell: bash
run: |
# the following fix the problem described in https://github.saobby.my.eu.orgmunity/t5/GitHub-Actions/Windows-tests-worked-yesterday-broken-today/m-p/43839#M5530
echo "C:\Program Files\Git\bin" >> ${GITHUB_PATH}
echo "VCPKG_ROBOTOLOGY_ROOT=C:/robotology/vcpkg" >> ${GITHUB_ENV}
- name: Display environment variables
shell: bash
run: env
Expand All @@ -57,19 +48,6 @@ jobs:
libmatio-dev libtinyxml-dev \
libace-dev libeigen3-dev
- name: Dependencies [Windows]
if: matrix.os == 'windows-latest'
shell: bash
run: |
choco install -y curl wget unzip
echo "Installing latest robotology-superbuild-dependencies-vcpkg"
cd C:/
wget https://github.com/robotology/robotology-superbuild-dependencies-vcpkg/releases/latest/download/vcpkg-robotology.zip
unzip vcpkg-robotology.zip -d C:/
rm vcpkg-robotology.zip
- name: Source-based Dependencies [Ubuntu]
if: matrix.os == 'ubuntu-latest'
shell: bash
Expand Down Expand Up @@ -97,32 +75,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
cmake --build . --config ${{ matrix.build_type }} --target install
- name: Source-based Dependencies [Windows]
if: matrix.os == 'windows-latest'
shell: bash
run: |
# YCM
cd ${GITHUB_WORKSPACE}
git clone https://github.com/robotology/ycm.git --depth 1 --branch master
cd ycm && mkdir -p build && cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROBOTOLOGY_ROOT}/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install ..
cmake --build . --config ${{ matrix.build_type }} --target INSTALL
if ${{matrix.yarp}}; then
# yarp
cd ${GITHUB_WORKSPACE}
git clone https://github.com/robotology/yarp.git --depth 1 --branch yarp-3.6
cd yarp && mkdir -p build && cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROBOTOLOGY_ROOT}/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install ..
cmake --build . --config ${{ matrix.build_type }} --target INSTALL
fi
# matio-cpp
cd ${GITHUB_WORKSPACE}
git clone https://github.com/dic-iit/matio-cpp.git --depth 1 --branch master
cd matio-cpp && mkdir -p build && cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROBOTOLOGY_ROOT}/scripts/buildsystems/vcpkg.cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install ..
cmake --build . --config ${{ matrix.build_type }} --target INSTALL
# ===================
# CMAKE-BASED PROJECT
# ===================
Expand All @@ -143,17 +95,6 @@ jobs:
cd build
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install -DROBOMETRY_VALGRIND_TESTS:BOOL=ON ..
- name: Configure [Windows]
# Use bash also on Windows (otherwise cd, mkdir, ... do not work)
if: matrix.os == 'windows-latest'
shell: bash
run: |
mkdir -p build
cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROBOTOLOGY_ROOT}/scripts/buildsystems/vcpkg.cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install -DBUILD_TESTING:BOOL=ON ..
- name: Build
shell: bash
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [1.2.2] - 2023-09-06

- Ported unit tests to catch v3.

## [1.2.0] - 2022-08-31

- Added `units_of_measure` parameter.
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

cmake_minimum_required(VERSION 3.12)
project(robometry LANGUAGES C CXX
VERSION 1.2.1)
VERSION 1.2.2)

include(GNUInstallDirs)
include(FeatureSummary)
Expand Down Expand Up @@ -132,17 +132,17 @@ set(ROBOMETRY_TEST_TIMEOUT ${ROBOMETRY_TEST_TIMEOUT_DEFAULT_VALGRIND})
if(BUILD_TESTING)

if(ROBOMETRY_USES_SYSTEM_Catch2)
find_package(Catch2 2.13.8 REQUIRED)
find_package(Catch 3.2.1 REQUIRED)
else()
include(FetchContent)

message(STATUS "Fetching Catch2...")
message(STATUS "Fetching Catch...")

FetchContent_Declare(Catch2
FetchContent_Declare(Catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.8)
GIT_TAG v3.2.1)

FetchContent_MakeAvailable(Catch2)
FetchContent_MakeAvailable(Catch)
endif()
enable_testing()
add_subdirectory(test)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The dependencies are:
- [Boost](https://www.boost.org/)
- [matio-cpp](https://github.com/dic-iit/matio-cpp#installation) (minimum version 0.1.1)
- [nlohmann_json](https://github.com/nlohmann/json#integration) (minimum version 3.10.0)
- [Catch2](https://github.com/catchorg/Catch2.git) (v2.13.1, for the unit tests)
- [Catch2](https://github.com/catchorg/Catch2.git) (v3.2.1, for the unit tests)

The optional dependencies are:
- [YARP](https://www.yarp.it/git-master/install.html) (minimum version 3.5.0)
Expand Down
2 changes: 1 addition & 1 deletion test/BufferManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CATCH_CONFIG_MAIN

#include <robometry/BufferManager.h>
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <vector>
#include <mutex>
#include <thread>
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_executable(bufferManager_test BufferManagerTest.cpp)
if(ROBOMETRY_BENCHMARKING)
target_compile_definitions(bufferManager_test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
endif()
target_link_libraries(bufferManager_test PRIVATE Catch2::Catch2
target_link_libraries(bufferManager_test PRIVATE Catch2::Catch2WithMain
matioCpp::matioCpp
Boost::boost
robometry::robometry)
Expand All @@ -24,7 +24,7 @@ function(robot_telemetry_catch_discover_tests _target)
set_property(TARGET ${_target} PROPERTY CROSSCOMPILING_EMULATOR "${ROBOMETRY_TEST_LAUNCHER}")
catch_discover_tests(
${_target}
EXTRA_ARGS "-s" "--use-colour" "yes"
EXTRA_ARGS "-s"
PROPERTIES
TIMEOUT ${ROBOMETRY_TEST_TIMEOUT}
SKIP_RETURN_CODE 254
Expand Down

0 comments on commit 6f17680

Please sign in to comment.