]> granicus.if.org Git - postgresql/commitdiff
Applied patch from Oliver Jowett to clean up the jdbc regression test build
authorBarry Lind <barry@xythos.com>
Mon, 11 Aug 2003 23:42:04 +0000 (23:42 +0000)
committerBarry Lind <barry@xythos.com>
Mon, 11 Aug 2003 23:42:04 +0000 (23:42 +0000)
 Modified Files:
  jdbc/build.xml
  jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java

src/interfaces/jdbc/build.xml
src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java

index 0e294f7136e0880b4a6ddbfb321ea9b307e02359..fed207ed8280656aee95e0be647d232a5ea561bc 100644 (file)
@@ -6,7 +6,7 @@
 
   This file now requires Ant 1.4.1.  2002-04-18
 
-  $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.34 2003/08/11 21:27:52 barry Exp $
+  $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.35 2003/08/11 23:42:04 barry Exp $
 
 -->
 
     </condition>
     <available property="datasource" classname="javax.sql.DataSource"/>
     <available property="ssl" classname="javax.net.ssl.SSLSocketFactory"/>
-    <available property="junit" classname="junit.framework.Test" />
+    <available property="junit" classname="junit.framework.Test"/>
+    <available property="junit.task" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
     <condition property="jdbc2tests">
       <and>
-        <isset property="jdbc2"/>
+        <or>
+          <isset property="jdbc2"/>
+          <isset property="jdbc3"/>
+        </or>
         <isset property="junit"/>
       </and>
     </condition>
     <condition property="jdbc2optionaltests">
       <and>
-        <isset property="jdbc2"/>
+        <or>
+          <isset property="jdbc2"/>
+          <isset property="jdbc3"/>
+        </or>
         <isset property="datasource"/>
         <isset property="junit"/>
       </and>
@@ -82,7 +89,6 @@
     <jar jarfile="${jardir}/postgresql.jar">
       <fileset dir="${builddir}">
         <include name="${package}/**/*.class" />
-        <exclude name="${package}/test/**" />
       </fileset>
 
       <fileset dir="${srcdir}">
   <property name="username" value="test" />
   <!-- Password must be something.  Doesn't matter if trust is used! -->
   <property name="password" value="password" />
-  <!-- junit.ui is one of textui, awtui, or swingui -->
-  <property name="junit.ui" value="textui" />
 
+  <!-- The tests now build to a separate directory and jarfile from the
+       driver build, to ensure we're really testing against the jar we just
+       built, and not whatever happens to be in builddir. -->
 
-  <target name="test" depends="testjdbc2,testjdbc2optional,testjdbc3">
-   </target>
+  <!-- This compiles and builds the test jarfile. -->  
+  <target name="testjar" depends="jar" if="junit">
+    <mkdir dir="${builddir}/tests"/>
+    <javac srcdir="${srcdir}" destdir="${builddir}/tests" debug="${debug}">
+      <include name="${package}/test/**" />
 
-  <target name="testjdbc2" depends="jar" if="jdbc2tests">
-    <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
-      <include name="${package}/test/jdbc2/*" />
-    </javac>
-   <java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
-      <arg value="org.postgresql.test.jdbc2.Jdbc2TestSuite" />
-      <sysproperty key="database" value="${database}" />
-      <sysproperty key="username" value="${username}" />
-      <sysproperty key="password" value="${password}" />
-      <classpath>
-        <pathelement location="${builddir}" />
-        <pathelement path="${java.class.path}" />
-      </classpath>
-    </java>
-  </target>
+      <exclude name="${package}/test/jdbc2/**" unless="jdbc2tests"/>
+      <exclude name="${package}/test/jdbc2/optional/**" unless="jdbc2optionaltests" />
+      <exclude name="${package}/test/jdbc3/**" unless="jdbc3tests" />
+      <exclude name="${package}/test/util/**" unless="jdbc2optionaltests"/>
 
-  <target name="testjdbc2optional" depends="jar" if="jdbc2optionaltests">
-    <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
-      <include name="${package}/test/jdbc2/optional/**" />
-      <include name="${package}/test/util/**" />
-    </javac>
-    <java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
-      <arg value="org.postgresql.test.jdbc2.optional.OptionalTestSuite" />
-      <sysproperty key="database" value="${database}" />
-      <sysproperty key="username" value="${username}" />
-      <sysproperty key="password" value="${password}" />
       <classpath>
-        <pathelement location="${builddir}" />
-        <pathelement path="${java.class.path}" />
+        <pathelement location="${jardir}/postgresql.jar"/>
       </classpath>
-    </java>
+    </javac>
+    <jar jarfile="${jardir}/postgresql-tests.jar" basedir="${builddir}/tests"/>
   </target>
+    
+  <!-- This actually runs the tests -->
+  <target name="runtest" depends="testjar" if="junit.task">
+    <junit>
+      <formatter type="brief" usefile="false"/>
 
-  <target name="testjdbc3" depends="jar" if="jdbc3tests">
-    <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
-      <include name="${package}/test/jdbc3/*" />
-      <include name="${package}/test/util/*" />
-    </javac>
-    <java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
-      <arg value="org.postgresql.test.jdbc3.Jdbc3TestSuite" />
       <sysproperty key="database" value="${database}" />
       <sysproperty key="username" value="${username}" />
       <sysproperty key="password" value="${password}" />
+
       <classpath>
-        <pathelement location="${builddir}" />
+        <pathelement location="${jardir}/postgresql.jar" />
+        <pathelement location="${jardir}/postgresql-tests.jar" />
         <pathelement path="${java.class.path}" />
       </classpath>
-    </java>
-  </target>
 
+      <test name="org.postgresql.test.jdbc2.Jdbc2TestSuite" if="jdbc2tests"/>
+      <test name="org.postgresql.test.jdbc2.optional.OptionalTestSuite" if="jdbc2optionaltests"/>
+      <test name="org.postgresql.test.jdbc3.Jdbc3TestSuite" if="jdbc3tests"/>
+    </junit>
+  </target>
+  
+  <!-- This is the target invoked by the Makefile -->
+  <target name="test" depends="testjar,runtest"/>
 
 </project>
index ec560213a9e048588a0442546c7dc44672090c36..d4b4ea087be2fc84ec723a4a45d083a7ce896415 100644 (file)
@@ -14,7 +14,6 @@ public class Jdbc3TestSuite extends TestSuite
        public static TestSuite suite()
        {
         TestSuite suite = new TestSuite();
-               suite.addTest(org.postgresql.test.jdbc2.Jdbc2TestSuite.suite());
         suite.addTestSuite(Jdbc3SimpleDataSourceTest.class);
         suite.addTestSuite(Jdbc3ConnectionPoolTest.class);
         suite.addTestSuite(Jdbc3PoolingDataSourceTest.class);