1#!/bin/bash 2 3rm -rf coverage 4mkdir coverage 5cd coverage 6mkdir binaries 7 8COMPILE_COMMAND=(g++ -O0 -W -Wall -Werror -std=c++11 -fprofile-arcs -fno-exceptions -ftest-coverage -I../include) 9FRUIT_OBJS=() 10 11 12for s in $(cd ../src; echo *.cpp) 13do 14 "${COMPILE_COMMAND[@]}" -c ../src/"$s" -o "src-${s/.cpp/.o}" & 15 FRUIT_OBJS+=("src-${s/.cpp/.o}") 16done 17 18wait || exit 1 19 20for testdir in $(find ../tests -type d) 21do 22 for t in $(cd $testdir; ls -1 *.cpp | fgrep -v include_test.cpp) 23 do 24 fgrep -q expect-compile-error $testdir/"$t" || \ 25 "${COMPILE_COMMAND[@]}" $testdir/"$t" ${FRUIT_OBJS[@]} -o binaries/${t/.cpp/} & 26 done 27done 28 29wait || exit 1 30 31for b in binaries/* 32do 33 ./"$b" || true 34done &>/dev/null 35 36PROJECT_DIR="$(cd ..; echo $PWD)" 37 38lcov --rc lcov_branch_coverage=1 -capture --directory . --output-file all-coverage.info 39lcov --rc lcov_branch_coverage=1 --base-directory "$PROJECT_DIR" \ 40 --extract all-coverage.info "$PROJECT_DIR/src/*" \ 41 --extract all-coverage.info "$PROJECT_DIR/include/*" \ 42 --output-file coverage.info 43genhtml --branch-coverage --demangle-cpp coverage.info --output-directory html 44 45xdg-open html/index.html 46