From 577b170b61f1ec9de1c9287cfe828f13b03683bc Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 24 Nov 2010 16:06:32 +0000
Subject: [PATCH] Fix coverage reports

Currently, the coverage reports include the unittests themselves, and
this skewes unfairly the reports, as the coverage for the tests is very
high (since they all run).

To fix this, we export the ganeti temp dir from run-in-temp-dir, and we
use that to exclude the tests directory. The patch also fixes a but
related to multiple directories to be omitted (--omit a --omit b is
wrong, it needs to be --omit a,b).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 autotools/gen-coverage   | 8 +++++---
 autotools/run-in-tempdir | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/autotools/gen-coverage b/autotools/gen-coverage
index f8f38658c..8d6c2d47e 100755
--- a/autotools/gen-coverage
+++ b/autotools/gen-coverage
@@ -24,10 +24,12 @@ set -e
 : ${PYTHON:=python}
 : ${COVERAGE_FILE:?}
 : ${TEXT_COVERAGE:?}
+: ${GANETI_TEMP_DIR:?}
 
-omit=$($PYTHON -c 'import sys;
-print " ".join(["--omit=%s/" % i for i in
-                set([sys.prefix, sys.exec_prefix])])')
+omit=$($PYTHON -c 'import sys; import os;
+print ",".join("%s/" % i for i in set([sys.prefix, sys.exec_prefix,
+   os.environ["GANETI_TEMP_DIR"] + "/test"]))')
+omit="--omit=$omit"
 
 $COVERAGE erase
 
diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir
index 9cab50fa1..4114346f7 100755
--- a/autotools/run-in-tempdir
+++ b/autotools/run-in-tempdir
@@ -8,4 +8,4 @@ trap "rm -rf $tmpdir" EXIT
 cp -r daemons scripts lib tools test $tmpdir
 mv $tmpdir/lib $tmpdir/ganeti
 
-cd $tmpdir && "$@"
+cd $tmpdir && GANETI_TEMP_DIR="$tmpdir" "$@"
-- 
GitLab