From 6e1f09694830f2ed655d1f3d4a400c16b315fde0 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 1 Apr 2020 17:30:11 -0400 Subject: [PATCH] Fix #346, Add test and coverage report to CI --- .travis.yml | 71 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bf2b9177..cacdfe414 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,22 +8,55 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - cmake - -before_install: - - sudo apt-get install cppcheck - -script: - # Check versions - - cppcheck --version - - #cppcheck flight software osal/src/bsp, osal/src/os - - cppcheck --force --inline-suppr --std=c99 --language=c --error-exitcode=1 --enable=warning,performance,portability,style --suppress=variableScope --inconclusive src/bsp src/os 2>cppcheck_flight_osal.txt - - | - if [[ -s cppcheck_flight_osal.txt ]]; then - echo "You must fix cppcheck errors before submitting a pull request" - echo "" - cat cppcheck_flight_osal.txt - exit -1 - fi - + - cmake cppcheck lcov + +_functional_test: &functional_test + script: + # Check versions + - cppcheck --version + + #cppcheck flight software osal/src/bsp, osal/src/os + - cppcheck --force --inline-suppr --std=c99 --language=c --error-exitcode=1 + --enable=warning,performance,portability,style --suppress=variableScope + --inconclusive --quiet src/bsp src/os 2>cppcheck_flight_osal.txt + - | + if [[ -s cppcheck_flight_osal.txt ]]; then + echo "You must fix cppcheck errors before submitting a pull request" + echo "" + cat cppcheck_flight_osal.txt + exit -1 + fi + + # Setup + - mkdir build + - cd build + + # Prep and build + - cmake -DENABLE_UNIT_TESTS=true -DOSAL_SYSTEM_OSTYPE=posix -DOSAL_SYSTEM_BSPTYPE=pc-linux + -DOSAL_INCLUDEDIR=src/bsp/pc-linux/config/ .. + - make + + # lcov capture pre-execution + - lcov --rc lcov_branch_coverage=1 --capture --initial --directory ./ --output-file coverage_base.info + + # Test + - make test + + # lcov post run analysis + - lcov --rc lcov_branch_coverage=1 --capture --directory ./ --output-file coverage_test.info + - lcov --rc lcov_branch_coverage=1 --add-tracefile coverage_base.info --add-tracefile + coverage_test.info --output-file coverage_total.info + - lcov --rc lcov_branch_coverage=1 --remove coverage_total.info '*unit-test-coverage*' + --output-file coverage_filtered.info + - genhtml coverage_filtered.info --output-directory lcov + +jobs: + include: + - env: BUILDTYPE=release OSAL_OMIT_DEPRECATED=true + <<: *functional_test + - env: BUILDTYPE=release OSAL_OMIT_DEPRECATED=false + <<: *functional_test + - env: BUILDTYPE=debug OSAL_OMIT_DEPRECATED=true + <<: *functional_test + - env: BUILDTYPE=debug OSAL_OMIT_DEPRECATED=false + <<: *functional_test