diff --git a/kodev b/kodev index 9d8ddfd67..7d5f24627 100755 --- a/kodev +++ b/kodev @@ -320,6 +320,63 @@ OPTIONS: popd } +function kodev-cov { + COV_HELP_MSG=" +usage: cov + +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 @@ -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}"