You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vm...@apache.org on 2005/02/22 17:03:24 UTC
svn commit: r154865 - in maven/maven-1/plugins/trunk/clover: ./
src/plugin-test/testCloverContexts/ src/plugin-test/testCloverContexts/src/
src/plugin-test/testCloverContexts/src/main/
src/plugin-test/testCloverContexts/src/main/org/
src/plugin-test/testCloverContexts/src/main/org/apache/
src/plugin-test/testCloverContexts/src/main/org/apache/maven/
src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/
src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/
src/plugin-test/testCloverContexts/src/test/
src/plugin-test/testCloverContexts/src/test/org/
src/plugin-test/testCloverContexts/src/test/org/apache/
src/plugin-test/testCloverContexts/src/test/org/apache/maven/
src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/
src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/
xdocs/
Author: vmassol
Date: Tue Feb 22 08:03:19 2005
New Revision: 154865
URL: http://svn.apache.org/viewcvs?view=rev&rev=154865
Log:
Add support for method, statement and block context filtering through the following properties: <code>maven.clover.context.block.names</code>, <code>maven.clover.context.method.names</code>, <code>maven.clover.context.method.regexps</code>, <code>maven.clover.context.statement.names</code> and <code>maven.clover.context.statement.regexps</code>.
Added:
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/maven.xml
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.properties
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.xml
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java (with props)
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/
maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java (with props)
Modified:
maven/maven-1/plugins/trunk/clover/plugin.jelly
maven/maven-1/plugins/trunk/clover/plugin.properties
maven/maven-1/plugins/trunk/clover/xdocs/changes.xml
maven/maven-1/plugins/trunk/clover/xdocs/properties.xml
Modified: maven/maven-1/plugins/trunk/clover/plugin.jelly
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/plugin.jelly?view=diff&r1=154864&r2=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/plugin.jelly (original)
+++ maven/maven-1/plugins/trunk/clover/plugin.jelly Tue Feb 22 08:03:19 2005
@@ -160,6 +160,20 @@
</j:if>
+ <!-- Define method contexts provided by users -->
+ <u:tokenize var="contextMethodNames" delim=",">${maven.clover.context.method.names}</u:tokenize>
+ <u:tokenize var="contextMethodRegexps" delim=",">${maven.clover.context.method.regexps}</u:tokenize>
+ <j:forEach var="contextMethodName" items="${contextMethodNames}">
+ <ant:methodContext name="${contextMethodName}" regexp="${contextMethodRegexps.remove(0)}"/>
+ </j:forEach>
+
+ <!-- Define statement contexts provided by users -->
+ <u:tokenize var="statementMethodNames" delim=",">${maven.clover.context.statement.names}</u:tokenize>
+ <u:tokenize var="statementMethodRegexps" delim=",">${maven.clover.context.statement.regexps}</u:tokenize>
+ <j:forEach var="statementMethodName" items="${statementMethodNames}">
+ <ant:statementContext name="${statementMethodName}" regexp="${statementMethodRegexps.remove(0)}"/>
+ </j:forEach>
+
</ant:clover-setup>
<echo>Now using primary build.compiler : ${build.compiler}</echo>
@@ -280,7 +294,15 @@
<ant:clover-report>
<ant:current outfile="${maven.build.dir}/clover.xml"
title="${pom.name} - ${pom.currentVersion}">
- <ant:format type="xml" orderBy="${maven.clover.orderBy}"/>
+ <ant:format type="xml" orderBy="${maven.clover.orderBy}">
+
+ <!-- Add context filtering -->
+ <j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
+ <j:if test="${!empty(contextFilters.trim())}">
+ <ant:setProperty name="filter" value="${contextFilters}"/>
+ </j:if>
+
+ </ant:format>
</ant:current>
</ant:clover-report>
</goal>
@@ -299,7 +321,15 @@
<ant:current
outfile="${cloverReportDirectory}"
title="${pom.name} - ${pom.currentVersion}">
- <ant:format type="html" orderBy="${maven.clover.orderBy}"/>
+ <ant:format type="html" orderBy="${maven.clover.orderBy}">
+
+ <!-- Add context filtering -->
+ <j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
+ <j:if test="${!empty(contextFilters.trim())}">
+ <ant:setProperty name="filter" value="${contextFilters}"/>
+ </j:if>
+
+ </ant:format>
</ant:current>
</ant:clover-report>
</goal>
@@ -387,6 +417,12 @@
<j:forEach var="package" items="${packages}">
<ant:package name="${package}" target="${targets.remove(0)}"/>
</j:forEach>
+
+ <!-- Add context filtering -->
+ <j:set var="contextFilters" value="${maven.clover.context.method.names} ${maven.clover.context.statement.names} ${maven.clover.context.block.names}"/>
+ <j:if test="${!empty(contextFilters.trim())}">
+ <ant:setProperty name="filter" value="${contextFilters}"/>
+ </j:if>
</ant:clover-check>
Modified: maven/maven-1/plugins/trunk/clover/plugin.properties
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/plugin.properties?view=diff&r1=154864&r2=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/plugin.properties (original)
+++ maven/maven-1/plugins/trunk/clover/plugin.properties Tue Feb 22 08:03:19 2005
@@ -68,3 +68,18 @@
# clover:check is called
# maven.clover.check.packages=my.package1,my.package2
# maven.clover.check.targets=10%,80%
+
+# List of Clover-defined block contexts to filter. Example:
+# maven.clover.context.block.names = static, method
+
+# List of user-defined method context names. Example:
+# maven.clover.context.method.names = name1, name2
+
+# List of user-defined methods context regexps. Example:
+# maven.clover.context.method.regexps = regexp1, regexp2
+
+# List of user-defined statement context names. Example:
+# maven.clover.context.statement.names = name3, name4
+
+# List of user-defined statement context regexps. Example:
+# maven.clover.context.statement.regexps = regexp3, regexp4
Added: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/maven.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/maven.xml?view=auto&rev=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/maven.xml (added)
+++ maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/maven.xml Tue Feb 22 08:03:19 2005
@@ -0,0 +1,42 @@
+<!--
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<project default="testPlugin"
+ xmlns:util="jelly:util"
+ xmlns:j="jelly:core"
+ xmlns:ant="jelly:ant"
+ xmlns:x="jelly:xml"
+ xmlns:maven="jelly:maven"
+ xmlns:assert="assert">
+
+ <goal name="testPlugin">
+
+ <attainGoal name="clean"/>
+
+ <attainGoal name="clover:test"/>
+ <j:catch var="exception">
+ <attainGoal name="clover:check"/>
+ </j:catch>
+
+ <!-- The test is successful if the total coverage is less than 33.4% -->
+ <j:if test="${empty(exception)}">
+ <ant:fail message="The test coverage should have been lower than 33.4%"/>
+ </j:if>
+
+ </goal>
+
+</project>
\ No newline at end of file
Added: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.properties
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.properties?view=auto&rev=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.properties (added)
+++ maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.properties Tue Feb 22 08:03:19 2005
@@ -0,0 +1,26 @@
+# -------------------------------------------------------------------
+# Copyright 2005 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -------------------------------------------------------------------
+
+maven.clover.context.method.names = methodsEndingWith1
+maven.clover.context.method.regexps = .*1.*
+
+maven.clover.context.statement.names = ifBlocks
+maven.clover.context.statement.regexps = .*if.*
+
+maven.clover.context.block.names = static
+
+# Test is successful is coverage is <= 33.3%
+maven.clover.check.target = 33.4%
Added: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.xml?view=auto&rev=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.xml (added)
+++ maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/project.xml Tue Feb 22 08:03:19 2005
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+<project>
+ <extend>${basedir}/../project.xml</extend>
+ <id>testCloverContexts</id>
+ <name>testCloverContexts</name>
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ </build>
+</project>
Added: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java?view=auto&rev=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java (added)
+++ maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java Tue Feb 22 08:03:19 2005
@@ -0,0 +1,43 @@
+package org.apache.maven.clover.test;
+
+/* ====================================================================
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+public class Simple
+{
+ static
+ {
+ System.getProperties();
+ }
+
+ public void someMethod1()
+ {
+ }
+
+ public void someMethodToReduceStatementCoverage()
+ {
+ System.getProperties();
+ }
+
+ public void someMethod2(int i)
+ {
+ if (i == 2)
+ {
+ // Do nothing
+ }
+ }
+}
\ No newline at end of file
Propchange: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/main/org/apache/maven/clover/test/Simple.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java?view=auto&rev=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java (added)
+++ maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java Tue Feb 22 08:03:19 2005
@@ -0,0 +1,30 @@
+package org.apache.maven.clover.test;
+
+/* ====================================================================
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+public class SimpleTest extends TestCase
+{
+ public void testSomeMethod()
+ {
+ Simple simple = new Simple();
+ simple.someMethod1();
+ simple.someMethod2(1);
+ }
+}
\ No newline at end of file
Propchange: maven/maven-1/plugins/trunk/clover/src/plugin-test/testCloverContexts/src/test/org/apache/maven/clover/test/SimpleTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: maven/maven-1/plugins/trunk/clover/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/xdocs/changes.xml?view=diff&r1=154864&r2=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/clover/xdocs/changes.xml Tue Feb 22 08:03:19 2005
@@ -27,6 +27,15 @@
<body>
<release version="1.8" date="in SVN">
<action dev="vmassol" type="add">
+ Add support for method, statement and block context filtering through
+ the following properties:
+ <code>maven.clover.context.block.names</code>,
+ <code>maven.clover.context.method.names</code>,
+ <code>maven.clover.context.method.regexps</code>,
+ <code>maven.clover.context.statement.names</code> and
+ <code>maven.clover.context.statement.regexps</code>.
+ </action>
+ <action dev="vmassol" type="add">
Added new <code>clover:check</code> goal that verifies if the
test coverage if above a threshold defined by the properties
<code>maven.clover.check.target</code>,
Modified: maven/maven-1/plugins/trunk/clover/xdocs/properties.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/clover/xdocs/properties.xml?view=diff&r1=154864&r2=154865
==============================================================================
--- maven/maven-1/plugins/trunk/clover/xdocs/properties.xml (original)
+++ maven/maven-1/plugins/trunk/clover/xdocs/properties.xml Tue Feb 22 08:03:19 2005
@@ -188,6 +188,64 @@
N/A
</td>
</tr>
+ <tr>
+ <td>maven.clover.context.block.names</td>
+ <td>Yes</td>
+ <td>
+ Comma-separated list of Clover-defined block contexts to filter
+ from the Clover coverage report.
+ Example: <code>maven.clover.context.block.names = static, method</code>.
+ </td>
+ <td>
+ N/A
+ </td>
+ </tr>
+ <tr>
+ <td>maven.clover.context.method.names</td>
+ <td>Yes</td>
+ <td>
+ Comma-separated list of user-defined method contexts to filter from
+ the Clover coverage report.
+ Example: <code>maven.clover.context.method.names = name1, name2</code>.
+ </td>
+ <td>
+ N/A
+ </td>
+ </tr>
+ <tr>
+ <td>maven.clover.context.method.regexps</td>
+ <td>Yes</td>
+ <td>
+ Regexps associated with <code>maven.clover.context.method.names</code>.
+ Example: <code>maven.clover.context.method.regexps = regexp1, regexp2</code>.
+ </td>
+ <td>
+ N/A
+ </td>
+ </tr>
+ <tr>
+ <td>maven.clover.context.statement.names</td>
+ <td>Yes</td>
+ <td>
+ Comma-separated list of user-defined statement contexts to filter from
+ the Clover coverage report.
+ Example: <code>maven.clover.context.statement.names = name3, name4</code>.
+ </td>
+ <td>
+ N/A
+ </td>
+ </tr>
+ <tr>
+ <td>maven.clover.context.statement.regexps</td>
+ <td>Yes</td>
+ <td>
+ Regexps associated with <code>maven.clover.context.statement.names</code>.
+ Example: <code>maven.clover.context.statement.regexps = regexp3, regexp4</code>.
+ </td>
+ <td>
+ N/A
+ </td>
+ </tr>
</table>
</section>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org