new ant target ("regress") to test regression bugs only:

Xml test cases with the regressionTest attribute set to false
(i.e. <test-code regressionTest="false">...) will be ignored when running the
"regress" or "regress14" ant targets.

current test status: two new false positives are added with this commit, for a
total of 3 failing tests with "ant test" and all regressions tests pass with
"ant regress".


git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5644 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch
2007-11-13 05:08:31 +00:00
parent 7488e9537d
commit c57746c0f2
8 changed files with 92 additions and 5 deletions

View File

@@ -179,6 +179,19 @@
<param name="test.outputdir" value="${dir.build}/reports"/>
<param name="test.jvm" value="java"/>
<param name="test.dependencies" value="dependencies.path"/>
<param name="test.regression" value="false"/>
</antcall>
<antcall target="test-report">
<param name="test.outputdir" value="${dir.build}/reports"/>
</antcall>
</target>
<target name="regress" depends="requires-junit,compile,copy" description="Runs the regression unit tests">
<antcall target="test-execute">
<param name="test.outputdir" value="${dir.build}/reports"/>
<param name="test.jvm" value="java"/>
<param name="test.dependencies" value="dependencies.path"/>
<param name="test.regression" value="true"/>
</antcall>
<antcall target="test-report">
<param name="test.outputdir" value="${dir.build}/reports"/>
@@ -189,6 +202,7 @@
<delete dir="${test.outputdir}" />
<mkdir dir="${test.outputdir}/xml"/>
<junit printsummary="yes" showoutput="no" filtertrace="yes" haltonfailure="no" jvm="${test.jvm}" forkmode="perBatch">
<sysproperty key="regress" value="${test.regression}"/>
<classpath>
<path refid="${test.dependencies}" />
</classpath>
@@ -237,6 +251,21 @@
<param name="test.outputdir" value="${dir.build}/reports14"/>
<param name="test.jvm" value="${jvm14.exe}"/>
<param name="test.dependencies" value="dependencies14.path"/>
<param name="test.regression" value="false"/>
</antcall>
<antcall target="test-report">
<param name="test.outputdir" value="${dir.build}/reports14"/>
</antcall>
</target>
<target name="regress14" depends="requires-junit,compile,copy,weavejunit,weave" description="Runs the regression unit tests with 1.4 jvm">
<fail unless="jvm14.exe" message="jvm14.exe location is not defined properly" />
<antcall target="test-execute">
<param name="test.outputdir" value="${dir.build}/reports14"/>
<param name="test.jvm" value="${jvm14.exe}"/>
<param name="test.dependencies" value="dependencies14.path"/>
<param name="test.regression" value="true"/>
</antcall>
<antcall target="test-report">
<param name="test.outputdir" value="${dir.build}/reports14"/>

View File

@@ -2,6 +2,7 @@
Fixed annotation bug: ClassCastException when a formal parameter had multiple annotations
Added a Visual Studio renderer for CPD; just use "--format vs".
Dependencies updates: asm to 3.1, retroweaver to 2.0.2, junit to 4.4
new ant target ("regress") to test regression bugs only
November 01, 2007 - 4.1rc1:
New rules:

View File

@@ -29,6 +29,9 @@
<!-- Reinitialize the rule for this test. For rules with caching (ie. XPath
rules with properties), only works if the rule was created with findRule -->
<xs:attribute name="reinitializeRule" type="xs:boolean" use="optional"/>
<!-- is the test a regression test, i.e. was it working in previous releases.
this defaults to true so that the attribute only needs to be set for failing tests -->
<xs:attribute name="regressionTest" type="xs:boolean" use="optional"/>
</xs:complexType>
</xs:element>

View File

@@ -232,7 +232,7 @@ public Object clone() throws CloneNotSupportedException {
}
]]></code>
</test-code>
<test-code>
<test-code regressionTest="false">
<description>
<![CDATA[
False +: Overriding method merely calls super (see bug 1415525)

View File

@@ -767,4 +767,36 @@ public class Foo {
}
]]></code>
</test-code>
</test-data>
<test-code regressionTest="false">
<description><![CDATA[
42, Using variable string array
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void foo(String[] a, int i) {
StringBuffer sb = new StringBuffer();
sb.append(a[i]).append("Hello");
sb.append(a[i+1]).append("World");
}
}
]]></code>
</test-code>
<test-code regressionTest="false">
<description><![CDATA[
43, Using variable char array
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
toString2(char[] a, int n){
StringBuffer sb = new StringBuffer();
sb.append("ab");
sb.append(a, 0, n);
sb.append('c');
return sb.toString();
}
}
]]></code>
</test-code>
</test-data>

View File

@@ -194,7 +194,16 @@ public abstract class RuleTst {
reinitializeRule = true;
}
}
boolean isRegressionTest = true;
Node regressionTestAttribute = testCode.getAttributes().getNamedItem("regressionTest");
if (regressionTestAttribute != null) {
String reinitializeRuleValue = regressionTestAttribute.getNodeValue();
if ("false".equalsIgnoreCase(reinitializeRuleValue)) {
isRegressionTest = false;
}
}
NodeList ruleProperties = testCode.getElementsByTagName("rule-property");
Properties properties = new Properties();
for (int j = 0; j < ruleProperties.getLength(); j++) {
@@ -238,6 +247,7 @@ public abstract class RuleTst {
}
}
tests[i].setReinitializeRule(reinitializeRule);
tests[i].setRegressionTest(isRegressionTest);
tests[i].setProperties(properties);
}
return tests;

View File

@@ -63,12 +63,15 @@ public abstract class SimpleAggregatorTst extends RuleTst {
*/
@Test
public void testAll() {
boolean regressionTest = Boolean.getBoolean("regress"); // get the "regress" System property
ArrayList<Failure> l = new ArrayList<Failure>();
for (Rule r : rules) {
TestDescriptor[] tests = extractTestsFromXml(r);
for (int i = 0; i < tests.length; i++) {
for (TestDescriptor test: tests) {
try {
runTest(tests[i]);
if (!regressionTest || test.isRegressionTest()) {
runTest(test);
}
} catch (Throwable t) {
Failure f = CustomXmlTestClassMethodsRunner.createFailure(r, t);
l.add(f);

View File

@@ -19,6 +19,7 @@ public class TestDescriptor {
private String code;
private SourceType sourceType;
private boolean reinitializeRule = false; //default
private boolean isRegressionTest = true;
public TestDescriptor(String code, String description, int numberOfProblemsExpected, Rule rule) {
this(code, description, numberOfProblemsExpected, rule, RuleTst.DEFAULT_SOURCE_TYPE);
@@ -67,4 +68,12 @@ public class TestDescriptor {
public void setReinitializeRule(boolean reinitializeRule) {
this.reinitializeRule = reinitializeRule;
}
public boolean isRegressionTest() {
return isRegressionTest;
}
public void setRegressionTest(boolean isRegressionTest) {
this.isRegressionTest = isRegressionTest;
}
}