summaryrefslogtreecommitdiff
path: root/utils/lit
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-01-31 00:21:44 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-01-31 00:21:44 +0000
commit412d805841da9ac25decbdf2aeda8e6d36109e89 (patch)
tree7f00f2c70c7df7289bd1b1c8c0a4ec79bdcd5693 /utils/lit
parent356dcac20e18f5125eb4f85e5dc1d1408f930099 (diff)
downloadllvm-412d805841da9ac25decbdf2aeda8e6d36109e89.tar.gz
llvm-412d805841da9ac25decbdf2aeda8e6d36109e89.tar.bz2
llvm-412d805841da9ac25decbdf2aeda8e6d36109e89.tar.xz
[lit] Add a script for checking test coverage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174000 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/tests/.coveragerc11
-rw-r--r--utils/lit/utils/README.txt2
-rwxr-xr-xutils/lit/utils/check-coverage50
3 files changed, 63 insertions, 0 deletions
diff --git a/utils/lit/tests/.coveragerc b/utils/lit/tests/.coveragerc
new file mode 100644
index 0000000000..f6764fe184
--- /dev/null
+++ b/utils/lit/tests/.coveragerc
@@ -0,0 +1,11 @@
+# .coveragerc to control coverage.py
+[run]
+branch = False
+parallel = False
+source = lit
+
+[html]
+directory = coverage_html_report
+
+[report]
+omit = Inputs
diff --git a/utils/lit/utils/README.txt b/utils/lit/utils/README.txt
new file mode 100644
index 0000000000..81862ba099
--- /dev/null
+++ b/utils/lit/utils/README.txt
@@ -0,0 +1,2 @@
+Utilities for the project that aren't intended to be part of a source
+distribution.
diff --git a/utils/lit/utils/check-coverage b/utils/lit/utils/check-coverage
new file mode 100755
index 0000000000..bb3d17e757
--- /dev/null
+++ b/utils/lit/utils/check-coverage
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+prog=$(basename $0)
+
+# Expect to be run from the parent lit directory.
+if [ ! -f setup.py ] || [ ! -d lit ]; then
+ printf 1>&2 "%s: expected to be run from base lit directory\n" "$prog"
+ exit 1
+fi
+
+# Parse command line arguments.
+if [ "$1" == "--generate-html" ]; then
+ GENERATE_HTML=1
+ shift
+fi
+
+# If invoked with no arguments, run all the tests.
+if [ $# == "0" ]; then
+ set -- "tests"
+fi
+
+# Check that the active python has been modified to enable coverage in its
+# sitecustomize.
+if ! python -c \
+ 'import sitecustomize, sys; sys.exit("coverage" not in dir(sitecustomize))' \
+ &> /dev/null; then
+ printf 1>&2 "error: active python does not appear to enable coverage in its 'sitecustomize.py'\n"
+ exit 1
+fi
+
+# First, remove any existing coverage data files.
+rm -f tests/.coverage
+find tests -name .coverage.\* -exec rm {} \;
+
+# Next, run the tests.
+lit -sv --param check-coverage=1 "$@"
+
+# Next, move all the data files from subdirectories up.
+find tests/* -name .coverage.\* -exec mv {} tests \;
+
+# Combine all the data files.
+(cd tests && python -m coverage combine)
+
+# Finally, generate the report.
+(cd tests && python -m coverage report)
+
+# Generate the HTML report, if requested.
+if [ ! -z "$GENERATE_HTML" ]; then
+ (cd tests && python -m coverage html)
+fi