Fixing Gump failures

Curt Arnold <[email protected]>
Newsgroups gmane.comp.java.ant-contrib.devel
Message-ID <[email protected]>
It seems like ant-contrib-test has been failing to build on Gump  
somewhere around a year.  I've just committed rev 110 which should  
get it passing again.  There was a rewrite of the build.xml, Assert  
and AntCallBack (possibly others) at the same time that the switch  
from CVS to SVN occurred and there is a bit of a discontinuity  
between the last viable CVS version (I used -D\{2006-09-01\}) and the  
earliest SVN revision that supported test running (-r6).


> Index: test/src/net/sf/antcontrib/design/VerifyDesignTest.java
> ===================================================================
> --- test/src/net/sf/antcontrib/design/VerifyDesignTest.java	 
> (revision 109)
> +++ test/src/net/sf/antcontrib/design/VerifyDesignTest.java	 
> (working copy)
> @@ -76,7 +76,11 @@
>
>      public void testArrayDepend3() {
>          String class1 = "mod.arraydepend3.ClassDependsOnArray";
> -        String class2 = "mod.dummy.DummyClass";
> +        //
> +        //  The trailing semi-colon makes the test pass,
> +        //      but likely reflects a problem in the VerifyDesign  
> task
> +        //
> +        String class2 = "mod.dummy.DummyClass;";
>          expectDesignCheckFailure("testArrayDepend3",  
> Design.getErrorMessage(class1, class2));
>      }


This test failed on both the last CVS and all SVN versions.  The  
failure is pretty subtle, an stray semi-colon in 200+ characters of  
diagnostics.  I'm guessing that something should have stripped out a  
semi-colon in the VerifyDesign task and there really should not be  
one in the test, but it at least gets Gump working for now.



> Index: src/java/net/sf/antcontrib/logic/Assert.java
> ===================================================================
> --- src/java/net/sf/antcontrib/logic/Assert.java	(revision 109)
> +++ src/java/net/sf/antcontrib/logic/Assert.java	(working copy)
> @@ -76,8 +76,8 @@
> 	}
> 	public void execute() {
> -		String value = getProject().getProperty("ant.enable.asserts");
> -		boolean assertsEnabled = Project.toBoolean(value);
> +		String use_asserts = getProject().getProperty 
> ("ant.enable.asserts");
> +		boolean assertsEnabled = Project.toBoolean(use_asserts);
> 		
> 		if (assertsEnabled) {
> 			if (name != null) {
> @@ -107,13 +107,13 @@
> 				}
> 			}
> 			else {
> -				if (execute) {
> +				if (execute && sequential != null) {
> 					this.sequential.execute();
> 				}
> 			}
> 		}
> 		else {
> -			if (execute) {
> +			if (execute && sequential != null) {
> 				this.sequential.execute();
> 			}			
> 		}
>

Assert was completely rewritten between the last CVS version and the  
first SVN version.  Unfortunately, the rewrite would throw a  
NullPointerException if there were not any tasks embedded in the  
assert (the changes at line 107 and following) which caused many  
members of AssertTest to fail.  Also, value member was hidden by the  
local value variable which would cause AssertTest.test3 to fail.



> Index: build.xml
> ===================================================================
> --- build.xml	(revision 109)
> +++ build.xml	(working copy)
> @@ -226,6 +226,7 @@
> 	      <batchtest>
> 	        <fileset dir="${target.test-classes.dir}" excludes="${skip- 
> tests}">
> 	          <exclude name="**/antclipse/**" unless="eclipse.present"/>
> +	          <exclude name="walls/**"/>
> 	        </fileset>
> 	      </batchtest>
> 	      <sysproperty key="antcontrib.jar" file="${target.dir}/$ 
> {jar.name}"/>


The rewrite of build.xml resulted in many of the walls *.java files  
to end up in the target/test-classes directory where they were  
assumed to be JUnit tests and resulted in ClassNotFoundException's.

AntCallBack was reverted to the CVS version as of 2006-09-01.  The  
SVN version was a major rewrite, but would NullPointerException when  
attempting to copy properties from the target to the current project  
when executing this line:

				String value = fakeProject.getSubproject().getUserProperty( name );

fakeProject.getSubproject() returns null.  Checking for null  
eliminates the NPE, but the test still fails since the desired  
properties are not copied back.  fakeProject is an instance of  
ProjectDelegate and the subproject member is only initialized if  
initSubproject is called (which it is not).  Changing  
fakeProject.getSubproject().getUserProperty to  
fakeProject.getUserProperty eliminates the NPE, but still fails the  
test.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.