Skip to content

Commit 7288835

Browse files
committed
CMake: Run the unit tests in travis CI
1 parent f93f71b commit 7288835

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.travis.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ addons:
3939
- sourceline: 'deb https://apt.kitware.com/ubuntu/ focal main'
4040
key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc'
4141
packages:
42-
- cmake
43-
- ninja-build
44-
- libncursesw5
42+
- cmake
43+
- ninja-build
44+
- gcovr
45+
- libncursesw5
46+
- g++-7
4547

4648
matrix:
4749
include:
@@ -321,3 +323,23 @@ matrix:
321323
- mbedtools configure -p ${ROOT} -t ${TOOLCHAIN} -m ${TARGET_NAME} --mbed-os-path .
322324
- cmake -S ${ROOT} -B ${ROOT}/cmake_build/${TARGET_NAME}/${PROFILE}/${TOOLCHAIN}/ -GNinja -DCMAKE_BUILD_TYPE=${PROFILE}
323325
- cmake --build ${ROOT}/cmake_build/${TARGET_NAME}/${PROFILE}/${TOOLCHAIN}/
326+
327+
### Mbed OS unittest ###
328+
- &cmake-build-run-unittest
329+
stage: "CMake"
330+
name: "CMake unittest build"
331+
env: NAME=cmake_unittest
332+
install:
333+
# Hide Travis-preinstalled CMake
334+
# The Travis-preinstalled CMake is unfortunately not installed via apt, so we
335+
# can't replace it with an apt-supplied version very easily. Additionally, we
336+
# can't permit the Travis-preinstalled copy to survive, as the Travis default
337+
# path lists the Travis CMake install location ahead of any place where apt
338+
# would install CMake to. Instead of apt removing or upgrading to a new CMake
339+
# version, we must instead delete the Travis copy of CMake.
340+
- sudo rm -rf /usr/local/cmake*
341+
script:
342+
- echo ctest --build-and-test . build --build-generator Ninja --build-options -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7 --test-command ctest
343+
- ctest --build-and-test . build --build-generator Ninja --build-options -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7 --test-command ctest
344+
- gcovr --gcov-executable gcov-7 -r . ./build -s -e ".*\.h" --exclude-directories=$TRAVIS_BUILD_DIR/build/UNITTESTS --exclude-directories=$TRAVIS_BUILD_DIR/build/_deps
345+
- ccache -s

0 commit comments

Comments
 (0)