mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-01-05 21:49:04 +01:00
Restore branch coverage for tests on Linux
This commit is contained in:
parent
1cbd1f933c
commit
15c72d4d99
@ -152,19 +152,20 @@ function measure_coverage()
|
||||
mkdir -p "${testResultsDir}"
|
||||
cp ${OUT_DIR}/*.gc* "${testResultsDir}"
|
||||
lcov --capture --directory "${testResultsDir}" --base-directory ${SRC_DIR} --test-name "${tcBaseName}" --quiet \
|
||||
--exclude '*/lex.yy.c' --exclude '*/parser.c' --rc branch_coverage=1 \
|
||||
--exclude '*/lex.yy.c' --exclude '*/parser.c' --rc "${branchCoverage}=1" \
|
||||
--output-file "${testResultsDir}/coverage.info"
|
||||
echo -n " Coverage: "
|
||||
lcov --summary "${testResultsDir}/coverage.info" 2>&1 | grep 'lines...' | grep -oP '\d+\.\d*%'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function consolidate_coverage()
|
||||
{
|
||||
echo -e "\nConsolidating test coverage ..."
|
||||
pushd ${OUT_DIR}/test-results || exit 1
|
||||
find . -name "*.info" | xargs printf -- '--add-tracefile %s\n' | xargs --exit \
|
||||
lcov --rc branch_coverage=1 --exclude '*/lex.yy.c' --exclude '*/parser.c' \
|
||||
lcov --rc "${branchCoverage}=1" --exclude '*/lex.yy.c' --exclude '*/parser.c' \
|
||||
--output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE}
|
||||
popd || exit 1
|
||||
echo ""
|
||||
@ -265,6 +266,11 @@ parse_arguments "$@"
|
||||
check_prereqs
|
||||
cov_baseline
|
||||
|
||||
declare branchCoverage=lcov_branch_coverage
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
branchCoverage=branch_coverage
|
||||
fi
|
||||
|
||||
# Execute the entire test suite
|
||||
if [ ${opt_suite} == true ]; then
|
||||
declare -i overallResult=0
|
||||
|
@ -21,6 +21,11 @@ declare -r tcBaseName=unittest
|
||||
declare -r testResultsDir=${OUT_DIR}/test-results/${tcBaseName}
|
||||
declare -r testReportDir=${OUT_DIR}/report-utest
|
||||
|
||||
declare branchCoverage=lcov_branch_coverage
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
branchCoverage=branch_coverage
|
||||
fi
|
||||
|
||||
if test -n "$(find ${OUT_DIR} -maxdepth 1 -name '*.gcda' -print -quit)" \
|
||||
&& test -n "$(find ${OUT_DIR} -maxdepth 1 -name '*.gcno' -print -quit)" \
|
||||
&& test -n "$(lcov --version)"
|
||||
@ -29,7 +34,7 @@ then
|
||||
mkdir -p ${testReportDir}
|
||||
cp ${OUT_DIR}/*.gc* ${testResultsDir}
|
||||
lcov --capture --directory ${testResultsDir} --base-directory ${SRC_DIR} --test-name ${tcBaseName} --quiet \
|
||||
--exclude '*/lex.yy.c' --exclude '*/parser.c' --rc branch_coverage=1 \
|
||||
--exclude '*/lex.yy.c' --exclude '*/parser.c' --rc "${branchCoverage}=1" \
|
||||
--output-file ${testResultsDir}/coverage.info
|
||||
echo -n "[ Coverage ] "
|
||||
genhtml --title "Boxes / Unit Tests" --branch-coverage --legend --output-directory ${testReportDir} \
|
||||
|
Loading…
Reference in New Issue
Block a user