[longomatch] Add new rules for coverage



commit 73658621008ccb2bb63d7e6866a47248af843096
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Mar 4 14:31:47 2015 +0100

    Add new rules for coverage

 Tests/Makefile.am          |   16 +++++++++++++++-
 Tests/Tests.csproj         |    4 ++--
 Tests/print_coverage.py    |   14 ++++++++++++++
 build/m4/shamrock/nunit.m4 |    4 ++++
 configure.ac               |    5 +++++
 5 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
index 36cc6c0..2eaf4ae 100644
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -17,5 +17,19 @@ RESOURCES = Core/dibujo.svg
 
 include $(top_srcdir)/build/build.mk
 
+if ENABLE_TESTS
 check:
-       nunit-console $(ASSEMBLY_FILE) --result=$(ASSEMBLY)-test-results.xml
+       $(NUNIT_CONSOLE) $(ASSEMBLY_FILE)
+if HAVE_COVEM
+coverage:
+       @rm -rf Tests.dll.covcfg.*
+       @BABOON_CFG=Tests.dll.covcfg $(COVEM) $(NUNIT_CONSOLE_EXE) $(ASSEMBLY_FILE) || true
+       @python print_coverage.py Tests.dll.covcfg.covreport
+show-coverage:
+       $(COV_GTK) $(ASSEMBLY).dll.covcfg.covdb
+endif
+endif
+
+CLEANFILES += \
+       Tests.dll.covcfg.*
+       TestsResult.xml
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index bc066fc..8445f27 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -14,7 +14,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
+    <OutputPath>..\bin\</OutputPath>
     <DefineConstants>DEBUG;</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -23,7 +23,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>full</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release</OutputPath>
+    <OutputPath>..\bin\</OutputPath>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
diff --git a/Tests/print_coverage.py b/Tests/print_coverage.py
new file mode 100755
index 0000000..b18f881
--- /dev/null
+++ b/Tests/print_coverage.py
@@ -0,0 +1,14 @@
+import sys
+
+lines_count=0
+matched_lines=0
+
+reportfile = sys.argv[1]
+with open(reportfile, 'r') as f:
+    for l in f.readlines():
+        if "Coverage=" in l:
+            continue
+        lines_count += 1
+        if not l.endswith (' 0\n'):
+            matched_lines += 1
+print "Coverage %s%%" % (matched_lines * 100 / lines_count)
diff --git a/build/m4/shamrock/nunit.m4 b/build/m4/shamrock/nunit.m4
index 14d0107..e8931fa 100644
--- a/build/m4/shamrock/nunit.m4
+++ b/build/m4/shamrock/nunit.m4
@@ -15,6 +15,10 @@ AC_DEFUN([SHAMROCK_CHECK_NUNIT],
                AC_SUBST(NUNIT_LIBS)
                AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
 
+               AC_PATH_PROG(NUNIT_CONSOLE, nunit-console, no)
+               NUNIT_CONSOLE_EXE=`cat $NUNIT_CONSOLE | tr ' ' '\n' | grep nunit-console.exe`
+               AC_SUBST(NUNIT_CONSOLE_EXE)
+
                if test "x$do_tests" = "xno"; then
                        PKG_CHECK_MODULES(NUNIT, mono-nunit >= 2.4,
                                do_tests="yes", do_tests="no")
diff --git a/configure.ac b/configure.ac
index a85c7ef..0268547 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,11 @@ SHAMROCK_FIND_MONO_RUNTIME
 dnl NUnit (optional)
 SHAMROCK_CHECK_NUNIT
 
+dnl Covem (optional)
+AC_PATH_PROG(COVEM, covem, no)
+AC_PATH_PROG(COV_GTK, cov-gtk, no)
+AM_CONDITIONAL(HAVE_COVEM, test x$COVEM != xno)
+
 dnl package checks, common for all configs
 PKG_CHECK_MODULES([GLIBSHARP], [glib-sharp-2.0])
 AC_SUBST(GLIBSHARP_LIBS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]