diff options
author | Moshe <moshehoa@amdocs.com> | 2019-03-03 12:06:08 +0200 |
---|---|---|
committer | Moshe <moshehoa@amdocs.com> | 2019-03-03 14:08:37 +0200 |
commit | 946470e3a794cc98e2d5b20af74ae3e5dac7d315 (patch) | |
tree | 4ac808375554f214da14aa97ca60241bee504845 /tools | |
parent | e10a5af4bb80d0a9ad4b0bd56959091ba5ff4a9a (diff) |
Allow multiple contexts per test case
Issue-ID: VNFSDK-350
Change-Id: Ib189a748bd41c48ef55959cecf221971d15099b5
Signed-off-by: Moshe <moshehoa@amdocs.com>
refactor context handling
Change-Id: Ic2bcdbcc98addeeef2cecd42c025a6a25b630b07
Signed-off-by: Moshe <moshehoa@amdocs.com>
produce coverage report
Issue-ID: VNFSDK-350
Change-Id: I88722d36710e09d8a2f9309a1214fd3ab53a8c83
Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cover.awk | 25 | ||||
-rw-r--r-- | tools/cover.sh | 80 |
2 files changed, 1 insertions, 104 deletions
diff --git a/tools/cover.awk b/tools/cover.awk deleted file mode 100644 index e4bb816..0000000 --- a/tools/cover.awk +++ /dev/null @@ -1,25 +0,0 @@ -BEGIN{ - template = "%6s %-75s\n" - printf template, "Delta", "Module Path" -} - -/^-/{ - s = substr($1, 2) - x[s] = $3; -}; - -/^+/{ - s = substr($1, 2) - d = $3 - if (s in x) - d = d - x[s] - y[s" "d] = d -} - -END{ - asorti(y, z1, "@val_num_asc") - for (i=1; i <= length(z1); i++){ - split(z1[i], z2, " ") - printf template, z2[2], z2[1] - } -} diff --git a/tools/cover.sh b/tools/cover.sh index fd9e9fe..e9b9cc5 100644 --- a/tools/cover.sh +++ b/tools/cover.sh @@ -23,94 +23,16 @@ else COVER_DIR_NAME=$( dirname $0 ) fi -show_diff () { - diff -U 0 $1 $2 | awk -f $COVER_DIR_NAME/cover.awk -} - run_coverage_test() { - ALLOWED_EXTRA_MISSING=150 # enable debugging set -x - # Stash uncommitted changes, checkout master and save coverage report - uncommited=$(git status --porcelain | grep -v "^??") - [[ -n ${uncommited} ]] && git stash > /dev/null - git checkout HEAD^ - - baseline_report=$(mktemp -t vnftest_coverageXXXXXXX) - - find . -type f -name "*.pyc" -delete - - coverage run -p -m unittest discover ./vnftest/tests/unit/core - coverage run -p -m unittest discover ./vnftest/tests/unit/onap - coverage run -p -m unittest discover ./vnftest/tests/unit/common - coverage combine - - coverage report > ${baseline_report} - coverage erase - - # debug awk - tail -1 ${baseline_report} - baseline_missing=$(awk 'END { if (int($3) > 0) print $3 }' ${baseline_report}) - - if [[ -z $baseline_missing ]]; then - echo "Failed to determine baseline missing" - exit 1 - fi - - # Checkout back and unstash uncommitted changes (if any) - git checkout - - [[ -n ${uncommited} ]] && git stash pop > /dev/null - - # Generate and save coverage report - current_report=$(mktemp -t vnftest_coverageXXXXXXX) - - find . -type f -name "*.pyc" -delete - coverage run -p -m unittest discover ./vnftest/tests/unit/core coverage run -p -m unittest discover ./vnftest/tests/unit/onap coverage run -p -m unittest discover ./vnftest/tests/unit/common coverage combine - - coverage report > ${current_report} + coverage xml coverage erase - rm -rf cover-$PY_VER - coverage html -d cover-$PY_VER - - # debug awk - tail -1 ${current_report} - current_missing=$(awk 'END { if (int($3) > 0) print $3 }' ${current_report}) - - if [[ -z $current_missing ]]; then - echo "Failed to determine current missing" - exit 1 - fi - - # Show coverage details - new_missing=$((current_missing - baseline_missing)) - - echo "Missing lines allowed to introduce : ${ALLOWED_EXTRA_MISSING}" - echo "Missing lines introduced : ${new_missing}" - echo "Missing lines in master : ${baseline_missing}" - echo "Missing lines in proposed change : ${current_missing}" - - if [[ ${new_missing} -gt ${ALLOWED_EXTRA_MISSING} ]]; - then - show_diff ${baseline_report} ${current_report} - echo "Please write more unit tests, we should keep our test coverage :( " - rm ${baseline_report} ${current_report} - exit 1 - - elif [[ ${new_missing} -gt 0 ]]; - then - show_diff ${baseline_report} ${current_report} - echo "I believe you can cover all your code with 100% coverage!" - - else - echo "Thank you! You are awesome! Keep writing unit tests! :)" - fi - - rm ${baseline_report} ${current_report} } |