Find coverage during configure, issue with Debian package
[ganeti-local] / autotools / gen-coverage
index ab16cc5..38bdd38 100755 (executable)
 set -e
 set -u
 
-: ${COVERAGE:=coverage}
 : ${PYTHON:=python}
+: ${COVERAGE:?}
 : ${COVERAGE_FILE:?}
 : ${TEXT_COVERAGE:?}
+: ${HTML_COVERAGE:=}
 : ${GANETI_TEMP_DIR:?}
 
 reportargs=(
@@ -34,6 +35,16 @@ reportargs=(
 
 $COVERAGE erase
 
+if [[ -n "$HTML_COVERAGE" ]]; then
+  if [[ ! -d "$HTML_COVERAGE" ]]; then
+    echo "Not a directory: $HTML_COVERAGE" >&2
+    exit 1
+  fi
+
+  # At least coverage 3.4 fails to overwrite files
+  find "$HTML_COVERAGE" \( -type f -o -type l \) -delete
+fi
+
 for script; do
   if [[ "$script" == *-runasroot.py ]]; then
     if [[ -z "$FAKEROOT" ]]; then