configtool/tests/build.xml
changeset 0 30eb2d538f02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configtool/tests/build.xml	Thu Mar 11 18:39:02 2010 +0200
@@ -0,0 +1,294 @@
+<!--****************************************************************************
+ * Configuration tool test cases 
+ * This ant build.xml will compile the system test cases and execute them.
+ ****************************************************************************-->
+<project name="ConfigurationTool system tests" default="all">  
+	  <property file="../common.properties"/>
+	  <property file="../install.properties"/>
+	  <property file="build.properties"/>
+	  <property file="../test.properties"/>
+	  
+    <!-- set global properties for this build -->
+    
+    <target name="all" depends="clean, init, resource, compile, test"/>
+
+    <target name="clean"> 
+        <delete dir="${tests.target}" quiet="true" />
+    </target>
+
+    <target name="clean-resource">
+        <delete dir="${install.dir}/testdata" quiet="true" />
+    </target>
+    
+    <!-- create the necessary folders -->
+    <target name="init">
+        <mkdir dir="${tests.target}/test-results"/>
+        <mkdir dir="${tests.target}/test-classes"/>
+    </target>
+    
+    <!-- copy the needed system testing data to the install folder -->
+		<target name="resource">
+			  <!-- Copy all from testdata to testdata -->
+			  <copy todir="${install.dir}/testdata">
+			  	  <fileset dir="${tests.data}" includes="**/*"/>
+			  </copy>  	
+		</target>
+
+	  <target name="compile" depends="init"
+		    description="compile the test source">
+		    <!-- Compile the java code from ${src} into ${build} -->
+        <javac srcdir="${tests.src}" destdir="${tests.target}/test-classes">
+            <classpath>
+                <pathelement location="lib/junit.jar"/>
+            </classpath>
+        </javac>
+	  </target>
+
+		<!-- nothing to do on jar target -->
+	  <target name="jar"/>
+	  
+		<!-- Build target will commit all the build steps and can be used for incremental 
+		building, because ant recognized changed files -->
+		<target name="build" depends="init, resource, compile, jar"/> 
+
+    <target name="test" depends="regtest,newtest,acctest"/>
+
+    <target name="acctest" depends="init,resource,compile">
+    	<junit haltonfailure="no" printsummary="on" timeout="500000" fork="on" dir="${install.dir}">
+	        <classpath>
+	            <pathelement location="${tests.target}/test-classes"/>
+	            <pathelement location="lib/junit.jar"/>
+	        </classpath>
+	        <formatter type="brief" usefile="true"/>
+	        <formatter type="xml" />          
+	        <batchtest todir="${tests.target}/test-results" >
+	            <fileset dir="${tests.target}/test-classes">
+	              <include name="acctest/Tc*.class"/>
+	             </fileset>
+	        </batchtest>
+    	</junit>        
+    </target>	
+    <target name="newtest" depends="init,resource,compile">
+        <junit haltonfailure="no" printsummary="on" fork="on" timeout="500000" dir="${install.dir}">
+            <classpath>
+                <pathelement location="${tests.target}/test-classes"/>
+                <pathelement location="lib/junit.jar"/>
+            </classpath>
+            <formatter type="brief" usefile="true"/>
+            <formatter type="xml" />          
+            <batchtest todir="${tests.target}/test-results" >
+                <fileset dir="${tests.target}/test-classes">
+                  <include name="newtest/Tc*.class"/>
+                 </fileset>
+            </batchtest>
+        </junit>
+    </target>
+    <target name="regtest" depends="init,resource,compile">
+        <junit haltonfailure="no" printsummary="on" fork="on" timeout="500000" dir="${install.dir}">
+            <classpath>
+                <pathelement location="${tests.target}/test-classes"/>
+                <pathelement location="lib/junit.jar"/>
+            </classpath>
+            <formatter type="brief" usefile="true"/>
+            <formatter type="xml" />          
+            <batchtest todir="${tests.target}/test-results" >
+                <fileset dir="${tests.target}/test-classes">
+                  <include name="regtest/Tc*.class"/>
+                 </fileset>
+            </batchtest>
+        </junit>
+    </target>
+
+  <!-- ==== COVERAGE ==== -->
+  
+  	<path id="tests.class.path">
+	    <path refid="project.class.path"/>
+	    <fileset dir="../tests/lib" casesensitive="no">
+	      <include name="*.jar"/>
+	    </fileset>
+	</path>
+
+	<path id="inst.class.path">
+	    <fileset dir="${common.plugin-lib}" casesensitive="no">
+	      <include name="**/*.jar"/>
+	    </fileset>
+	    <fileset dir="${common.plugin-dist}" casesensitive="no">
+	      <include name="**/*.jar"/>
+	      <include name="*.jar"/>
+	    </fileset>
+	</path>
+	
+		<path id="test.inst.class.path">
+	    <fileset dir="${common.plugin-lib}" casesensitive="no">
+	      <include name="**/*.jar"/>
+	    </fileset>
+	    <fileset dir="${common.plugin-dist}" casesensitive="no">
+	      <include name="**/*.jar"/>
+	      <include name="*.jar"/>
+	    </fileset>
+ 	    <fileset dir="../tests/lib" casesensitive="no">
+	      <include name="*.jar"/>
+	    </fileset>
+
+	</path>
+
+	<!-- Set emma.lib to refer to the list of EMMA jar files -->
+	<path id="emma.lib" >
+	    <fileset dir="lib">
+	        <include name="*.jar"/>
+	    </fileset>
+	</path>
+
+	<!-- Define which classes will be reported in the coverage reports -->
+	<!-- (by default, we will include all classes and assume -->
+	<!-- that your project's output folder is target/classes -->
+	<path id="emma.coverage.classes" >
+	    <pathelement location="build/bin" />
+	</path>
+
+	<!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT -->
+	<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
+
+	<target name="_inst_compile" >
+	  <echo message="plugin-build-template.xml ${pluginName} _inst_compile" level="debug"/>
+		<!--<antcall target="inst_compile"/>-->
+		<!--<antcall target="jar"/>-->
+	</target>
+
+  <target name="_test_coverage" >
+  	<echo message="plugin-build-template.xml ${pluginName} _test_coverage" level="debug"/>
+  	<antcall target="init_test"/>
+  	<antcall target="test_compile"/>
+  	<antcall target="test_coverage_execution"/>
+  	<antcall target="test_coverage_report"/>
+  </target>
+
+  <target name="resource_inst" depends="init">
+    <echo message="plugin-build-template.xml ${pluginName} resource" level="debug"/>
+    <copy todir="${common.plugin-target}/inst/">
+      <fileset refid="plugin-resources" /> 
+    </copy>
+    <copy todir="${common.plugin-target}/bin/">
+      	<fileset dir="${common.plugin-src.dir}" includes="**/*.properties"/>
+      	<fileset dir="${common.plugin-src.dir}" includes="**/*.tokens"/>
+      	<fileset dir="${common.plugin-src.dir}" includes="**/*.g"/>
+      	<fileset dir="${common.plugin-src.dir}" includes="**/*.txtjet"/>
+    </copy>
+  </target>
+
+ <target name="compile_inst" depends="emma, resource, resource_inst" description="compile the source with instrumentation">
+    <echo message="plugin-build-template.xml ${pluginName} compile_inst" level="debug"/>
+    <!-- Update manifest file with value from -Dversion=string -->
+    <manifest file="${common.plugin-target}/bin/META-INF/MANIFEST.MF" mode="update">
+  		<attribute name="Bundle-ReleaseVersion" value="${common.releaseversion}"/>
+  		<attribute name="Bundle-Date" value="${common.builddate}"/>
+  		<attribute name="Bundle-RepositoryVersion" value="${common.svnversion}"/>
+  	</manifest>
+  	
+    <!-- Compile the java code from ${src} into ${build} -->
+    <javac executable="${common.javac-exe}" 
+    				debug="on" 
+    				verbose="${common.javac-verbose}" 
+    				fork="${common.javac-fork}" 
+    				compiler="${common.javac-compiler}" 
+    				srcdir="${common.plugin-src.dir}" 
+    				destdir="${common.plugin-target}/bin" 
+    				target="${common.javac-target}" 
+    				source="${common.javac-source}">
+      <classpath refid="inst.class.path"/>
+    </javac>
+    
+     <emma enabled="true"> 
+    	<instr instrpathref="emma.coverage.classes"
+         destdir="${common.instr.dir}"
+         metadatafile="${common.unittest.reports.emma.dir}/${pluginName}-metadata.emma"
+         merge="true">
+        <filter value="${emma.filter}" />
+  	  </instr>
+		</emma>
+
+	  <copy todir="${common.plugin-target}/bin">  	
+ 		    <fileset dir="${common.instr.dir}" >
+		        <include name="**/*.class" />
+		    </fileset>
+	  </copy>	  
+    
+  </target>
+
+  <target name="test_coverage_execution" >
+    <echo message="plugin-build-template.xml ${pluginName} test_coverage_execution" level="debug"/>
+
+  	<junit printsummary="yes" haltonfailure="no" fork="true">
+			<classpath>
+			  <pathelement location="${common.unittest.bin.dir}"/>
+			  <pathelement location="${common.instr.dir}"/>
+				<path refid="test.inst.class.path"/>
+				<path refid="emma.lib" />
+			</classpath>
+			
+			<formatter type="xml"/>
+	
+			<batchtest todir="${common.unittest.reports.dir}">
+				<fileset dir="${common.unittest.bin.dir}">
+					<include name="**/*Test*.class"/>
+					<exclude name="**/AllTests.class"/> 
+				</fileset>
+			</batchtest>
+			
+			<jvmarg value="-Demma.coverage.out.file=${pluginName}/${common.unittest.reports.emma.dir}/${pluginName}-coverage.emma" />
+			<jvmarg value="-Demma.coverage.out.merge=true" />
+		</junit>
+  </target>    
+  
+	<target name="emma" description="turns on EMMA's instrumentation/reporting" >
+	    <echo message="plugin-build-template.xml ${pluginName} emma" level="debug"/>
+	    <property name="emma.enabled" value="true" />
+
+	    <mkdir dir="${common.instr.dir}" />
+	    
+	    <property name="emma.filter" value="" />
+	</target>
+	
+	<target name="test_coverage_report">
+		<echo message="plugin-build-template.xml ${pluginName} test_coverage_report" level="debug"/>
+  
+  	<junitreport todir="${common.unittest.reports.dir}">
+				<fileset dir="${common.unittest.reports.dir}">
+					<include name="TEST-*.xml"/>
+				</fileset>
+				<report format="frames" todir="${common.unittest.reports.dir}/html"/>
+  	</junitreport>
+  	<copy todir="../tests/emma/src">
+  	    <fileset dir="src">
+					<include name="**/*.java"/>
+				</fileset>
+	  </copy>
+
+  	<copy todir="../tests/target/test-results/">
+  	    <fileset dir="${common.unittest.reports.dir}">
+					<include name="TEST-*.xml"/>
+				</fileset>
+	  </copy>
+
+  	<copy todir="../tests/target/emma">
+  	    <fileset dir="${common.unittest.reports.emma.dir}">
+					<include name="*.emma"/>
+				</fileset>
+	  </copy>
+
+
+  	<!-- if enabled, generate coverage report(s): -->
+		<!--<emma enabled="true">
+		    <report sourcepath="${common.plugin-src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
+		    <fileset dir="${common.unittest.reports.emma.dir}" >
+		        <include name="*.emma" />
+		    </fileset>
+		    <xml outfile="${common.unittest.reports.emma.dir}/coverage.xml" depth="package"/>
+		    <html outfile="${common.unittest.reports.emma.dir}/coverage.html" depth="method" columns="name,class,method,block,line"/>
+	    </report>
+		</emma>-->
+		
+  </target>    
+
+
+</project>
\ No newline at end of file