Merge pull request #52 from linuxdeploy/generate-coverage-reports

Generate coverage reports
This commit is contained in:
TheAssassin
2018-11-10 19:54:05 +01:00
committed by GitHub
4 changed files with 90 additions and 6 deletions

View File

@@ -26,6 +26,36 @@ matrix:
- automake # required for patchelf
- libfuse2:i386
- libcairo2:i386
- env: ARCH=x86_64 BUILD_TYPE=coverage
addons:
apt:
update: true
packages:
- libmagic-dev
- libjpeg-dev
- libpng-dev
- cimg-dev
before_script:
- sudo pip install gcovr
script: travis/test-coverage.sh
after_success: true # also, we don't intend to upload release binaries
- env: ARCH=i386 BUILD_TYPE=coverage
addons:
apt:
update: true
packages:
- libmagic-dev:i386
- libjpeg-dev:i386
- libpng-dev:i386
- gcc-multilib
- g++-multilib
- libfuse2:i386
- libcairo2:i386
before_script:
- sudo pip install gcovr
script: travis/test-coverage.sh
after_success: true # also, we don't intend to upload release binaries
install:
- git clone https://github.com/NixOS/patchelf.git -b 0.8
@@ -44,7 +74,7 @@ script:
after_success:
- ls -lh
# make sure only pushes to rewrite create a new release, otherwise pretend PR and upload to transfer.sh
- if [ "$TRAVIS_TAG" != "$TRAVIS_BRANCH" ] && [ "$TRAVIS_BRANCH" == "master" ]; then export TRAVIS_EVENT_TYPE=pull_request; fi
- if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" != "master" ]; then export TRAVIS_EVENT_TYPE=pull_request; fi
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- bash upload.sh linuxdeploy-"$ARCH".AppImage*

View File

@@ -10,6 +10,20 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/
set(USE_SYSTEM_BOOST OFF CACHE BOOL "Set to ON to use system boost libraries instead of building up to date boost libraries from source")
set(USE_SYSTEM_CIMG ON CACHE BOOL "Set to OFF to use CImg library bundled in lib directory")
# support for ccache
# call CMake with -DUSE_CCACHE=ON to make use of it
set(USE_CCACHE ON CACHE BOOL "")
if(USE_CCACHE)
find_program(CCACHE ccache)
if(CCACHE)
message(STATUS "Using ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
else()
message(WARNING "USE_CCACHE set, but could not find ccache")
endif()
endif()
set(ENABLE_COVERAGE OFF CACHE BOOL "Enable coverage measurements")
if(ENABLE_COVERAGE)
include(CodeCoverage)
@@ -20,14 +34,13 @@ if(ENABLE_COVERAGE)
set(COVERAGE_GCOVR_EXCLUDES ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR})
include(ProcessorCount)
ProcessorCount(PROCESSOR_COUNT)
ProcessorCount(processor_count)
set(command ctest -V -j ${PROCESSOR_COUNT})
set(command cmake --build . --target all -- -j ${processor_count} && ctest -V)
setup_target_for_coverage_gcovr_html(NAME coverage EXECUTABLE "${command}")
setup_target_for_coverage_gcovr_xml(NAME coverage_xml EXECUTABLE "${command}")
setup_target_for_coverage_gcovr_text(NAME coverage_text EXECUTABLE "${command}")
setup_target_for_coverage_lcov(NAME coverage_lcov EXECUTABLE "${command}")
endif()
add_subdirectory(lib)

View File

@@ -71,11 +71,11 @@ namespace AppDirTest {
}
TEST_F(AppDirUnitTestsFixture, depoloyLibraryWrongPath) {
TEST_F(AppDirUnitTestsFixture, deployLibraryWrongPath) {
ASSERT_THROW(appDir.deployLibrary("/lib/fakelib.so"), std::exception);
}
TEST_F(AppDirUnitTestsFixture, depoloyLibrary) {
TEST_F(AppDirUnitTestsFixture, deployLibrary) {
appDir.deployLibrary(SIMPLE_LIBRARY_PATH);
appDir.executeDeferredOperations();

41
travis/test-coverage.sh Executable file
View File

@@ -0,0 +1,41 @@
#! /bin/bash
set -e
set -x
# use RAM disk if possible
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
TEMP_BASE=/dev/shm
else
TEMP_BASE=/tmp
fi
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" linuxdeploy-build-XXXXXX)
cleanup () {
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
trap cleanup EXIT
# store repo root as variable
REPO_ROOT=$(readlink -f $(dirname $(dirname $0)))
OLD_CWD=$(readlink -f .)
pushd "$BUILD_DIR"
if [ "$ARCH" == "x86_64" ]; then
EXTRA_CMAKE_ARGS=()
elif [ "$ARCH" == "i386" ]; then
EXTRA_CMAKE_ARGS=("-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/toolchains/i386-linux-gnu.cmake" "-DUSE_SYSTEM_CIMG=OFF")
else
echo "Architecture not supported: $ARCH" 1>&2
exit 1
fi
cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON "${EXTRA_CMAKE_ARGS[@]}"
# build, run tests and show coverage report
make -j$(nproc) coverage_text