summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJim Rollenhagen <jim@jimrollenhagen.com>2020-08-11 15:53:42 -0400
committerAkihiro Motoki <amotoki@gmail.com>2020-10-05 15:32:06 +0900
commit1202faa70901588f91c7ab61e31fb8215c72445d (patch)
tree81b63985779e59b179e4051f78b8ea3ce2853920 /tools
parent79e505520fc307eeedc1f5c81fb516e9638ebd72 (diff)
downloadhorizon-1202faa70901588f91c7ab61e31fb8215c72445d.tar.gz
Fix coverage job
`coverage run pytest` runs coverage against the tests in a file called "pytest", whereas `coverage run -m pytest` uses pytest as the test runner, which is what we really want here. To avoid duplicated maitenance of pytest arguments, unit_tests.sh is updated to handle the coverage run. Co-Authored-By: Akihiro Motoki <amotoki@gmail.com> Change-Id: I106cb5227ca8c4f0a6f9d81c37e745a6f304de45
Diffstat (limited to 'tools')
-rwxr-xr-xtools/unit_tests.sh21
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/unit_tests.sh b/tools/unit_tests.sh
index 2a0374af7..45da9e9b1 100755
--- a/tools/unit_tests.sh
+++ b/tools/unit_tests.sh
@@ -1,3 +1,12 @@
+# Usage: unit_tests.sh [--coverage] <root_dir> [<test-file>, ...]
+
+if [ "$1" = "--coverage" ]; then
+ shift
+ coverage=1
+else
+ coverage=0
+fi
+
root=$1
posargs="${@:2}"
@@ -52,11 +61,15 @@ function run_test {
fi
fi
- report_args="--junitxml=$report_dir/${project}_test_results.xml"
- report_args+=" --html=$report_dir/${project}_test_results.html"
- report_args+=" --self-contained-html"
+ if [ "$coverage" -eq 1 ]; then
+ coverage run -m pytest $target --ds=$settings_module -m "$tag"
+ else
+ report_args="--junitxml=$report_dir/${project}_test_results.xml"
+ report_args+=" --html=$report_dir/${project}_test_results.html"
+ report_args+=" --self-contained-html"
- pytest $target --ds=$settings_module -v -m "$tag" $report_args
+ pytest $target --ds=$settings_module -v -m "$tag" $report_args
+ fi
return $?
}