Find coverage during configure, issue with Debian package
authorMichael Hanselmann <hansmi@google.com>
Mon, 22 Oct 2012 15:05:16 +0000 (17:05 +0200)
committerMichael Hanselmann <hansmi@google.com>
Mon, 22 Oct 2012 15:42:41 +0000 (17:42 +0200)
- Debian Squeeze and up have a package named “python-coverage”, but it
  doesn't use the same binary name as upstream (“coverage”).
- Said package includes a patch to use symlinks instead of file copies
  for jQuery. If files from previous runs are around, an exception is
  raised. This is fixed by removing all regular files and symlinks
  before generating a report.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

Makefile.am
autotools/gen-coverage
configure.ac

index 3314aa2..f9b4a94 100644 (file)
@@ -1640,7 +1640,10 @@ endif
 
 .PHONY: py-coverage
 py-coverage: $(GENERATED_FILES) $(python_tests)
 
 .PHONY: py-coverage
 py-coverage: $(GENERATED_FILES) $(python_tests)
+       @test -n "$(PYCOVERAGE)" || \
+           { echo 'python-coverage' not found during configure; exit 1; }
        set -e; \
        set -e; \
+       COVERAGE=$(PYCOVERAGE) \
        COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
        TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
        HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
        COVERAGE_FILE=$(CURDIR)/$(COVERAGE_PY_DIR)/data \
        TEXT_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR)/report.txt \
        HTML_COVERAGE=$(CURDIR)/$(COVERAGE_PY_DIR) \
index ab16cc5..38bdd38 100755 (executable)
 set -e
 set -u
 
 set -e
 set -u
 
-: ${COVERAGE:=coverage}
 : ${PYTHON:=python}
 : ${PYTHON:=python}
+: ${COVERAGE:?}
 : ${COVERAGE_FILE:?}
 : ${TEXT_COVERAGE:?}
 : ${COVERAGE_FILE:?}
 : ${TEXT_COVERAGE:?}
+: ${HTML_COVERAGE:=}
 : ${GANETI_TEMP_DIR:?}
 
 reportargs=(
 : ${GANETI_TEMP_DIR:?}
 
 reportargs=(
@@ -34,6 +35,16 @@ reportargs=(
 
 $COVERAGE erase
 
 
 $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
 for script; do
   if [[ "$script" == *-runasroot.py ]]; then
     if [[ -z "$FAKEROOT" ]]; then
index 3d7eaa3..da46415 100644 (file)
@@ -373,7 +373,16 @@ if test -z "$PEP8"
 then
   AC_MSG_WARN([pep8 not found, checking code will not be complete])
 fi
 then
   AC_MSG_WARN([pep8 not found, checking code will not be complete])
 fi
-AM_CONDITIONAL([HAS_PEP8], [test "$PEP8"])
+AM_CONDITIONAL([HAS_PEP8], [test -n "$PEP8"])
+
+# Check for python-coverage
+AC_ARG_VAR(PYCOVERAGE, [python-coverage path])
+AC_PATH_PROGS(PYCOVERAGE, [python-coverage coverage], [])
+if test -z "$PYCOVERAGE"
+then
+  AC_MSG_WARN(m4_normalize([python-coverage or coverage not found, evaluating
+                            Python test coverage will not be possible]))
+fi
 
 # Check for socat
 AC_ARG_VAR(SOCAT, [socat path])
 
 # Check for socat
 AC_ARG_VAR(SOCAT, [socat path])