kodev(feat): add cov command

pull/2629/head
Qingping Hou 7 years ago committed by Frans de Jonge
parent 2aa9d5d64e
commit 7241575f42

59
kodev

@ -320,6 +320,63 @@ OPTIONS:
popd
}
function kodev-cov {
COV_HELP_MSG="
usage: cov <OPTIONS>
OPTIONS:
--show-previous show coverage stats from previous run
--full show full coverage report (down to each line)
"
show_full=0
show_previous=0
while [[ $1 == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
--full)
show_full=1 ;;
--show-previous)
show_previous=1 ;;
-h | --help)
echo "${COV_HELP_MSG}"; exit 0 ;;
*)
echo "ERROR: unknown option \"$PARAM\""
echo "${COV_HELP_MSG}"; exit 1 ;;
esac
shift
done
check_submodules && make
setup_env
make "${EMU_DIR}/.busted"
pushd "${EMU_DIR}"
target=front
test_path="./spec/${target}/unit"
if [ ${show_previous} -eq 0 ]; then
echo "Running tests in" ${test_path}
busted --lua="./luajit" \
--sort-files \
--no-auto-insulate \
--lazy \
-o "./spec/${target}/unit/verbose_print" \
--coverage \
--exclude-tags=nocov "${test_path}" || {
echo "Failed to run tests!" && exit 1;
}
fi
if [ ${show_full} -eq 1 ]; then
cat luacov.report.out
else
tail -n \
+$(($(grep -nm1 -e '^Summary$' luacov.report.out|cut -d: -f1)-1)) \
luacov.report.out
fi
popd
}
function kodev-log {
LOG_HELP_MSG="
usage: log <TARGET>
@ -380,6 +437,8 @@ case $1 in
shift 1; kodev-run "$@" ;;
test)
shift 1; kodev-test "$@" ;;
cov)
shift 1; kodev-cov "$@" ;;
prompt)
kodev-build
pushd "${EMU_DIR}"

Loading…
Cancel
Save