mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-20 01:37:52 +02: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}"
|
mkdir -p "${testResultsDir}"
|
||||||
cp ${OUT_DIR}/*.gc* "${testResultsDir}"
|
cp ${OUT_DIR}/*.gc* "${testResultsDir}"
|
||||||
lcov --capture --directory "${testResultsDir}" --base-directory ${SRC_DIR} --test-name "${tcBaseName}" --quiet \
|
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"
|
--output-file "${testResultsDir}/coverage.info"
|
||||||
echo -n " Coverage: "
|
echo -n " Coverage: "
|
||||||
lcov --summary "${testResultsDir}/coverage.info" 2>&1 | grep 'lines...' | grep -oP '\d+\.\d*%'
|
lcov --summary "${testResultsDir}/coverage.info" 2>&1 | grep 'lines...' | grep -oP '\d+\.\d*%'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function consolidate_coverage()
|
function consolidate_coverage()
|
||||||
{
|
{
|
||||||
echo -e "\nConsolidating test coverage ..."
|
echo -e "\nConsolidating test coverage ..."
|
||||||
pushd ${OUT_DIR}/test-results || exit 1
|
pushd ${OUT_DIR}/test-results || exit 1
|
||||||
find . -name "*.info" | xargs printf -- '--add-tracefile %s\n' | xargs --exit \
|
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}
|
--output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE}
|
||||||
popd || exit 1
|
popd || exit 1
|
||||||
echo ""
|
echo ""
|
||||||
@ -265,6 +266,11 @@ parse_arguments "$@"
|
|||||||
check_prereqs
|
check_prereqs
|
||||||
cov_baseline
|
cov_baseline
|
||||||
|
|
||||||
|
declare branchCoverage=lcov_branch_coverage
|
||||||
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
branchCoverage=branch_coverage
|
||||||
|
fi
|
||||||
|
|
||||||
# Execute the entire test suite
|
# Execute the entire test suite
|
||||||
if [ ${opt_suite} == true ]; then
|
if [ ${opt_suite} == true ]; then
|
||||||
declare -i overallResult=0
|
declare -i overallResult=0
|
||||||
|
@ -21,6 +21,11 @@ declare -r tcBaseName=unittest
|
|||||||
declare -r testResultsDir=${OUT_DIR}/test-results/${tcBaseName}
|
declare -r testResultsDir=${OUT_DIR}/test-results/${tcBaseName}
|
||||||
declare -r testReportDir=${OUT_DIR}/report-utest
|
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)" \
|
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 "$(find ${OUT_DIR} -maxdepth 1 -name '*.gcno' -print -quit)" \
|
||||||
&& test -n "$(lcov --version)"
|
&& test -n "$(lcov --version)"
|
||||||
@ -29,7 +34,7 @@ then
|
|||||||
mkdir -p ${testReportDir}
|
mkdir -p ${testReportDir}
|
||||||
cp ${OUT_DIR}/*.gc* ${testResultsDir}
|
cp ${OUT_DIR}/*.gc* ${testResultsDir}
|
||||||
lcov --capture --directory ${testResultsDir} --base-directory ${SRC_DIR} --test-name ${tcBaseName} --quiet \
|
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
|
--output-file ${testResultsDir}/coverage.info
|
||||||
echo -n "[ Coverage ] "
|
echo -n "[ Coverage ] "
|
||||||
genhtml --title "Boxes / Unit Tests" --branch-coverage --legend --output-directory ${testReportDir} \
|
genhtml --title "Boxes / Unit Tests" --branch-coverage --legend --output-directory ${testReportDir} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user