Re: patch: clean up ant test infrastructure

From: Barry Lind <blind(at)xythos(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: patch: clean up ant test infrastructure
Date: 2003-08-11 23:42:58
Message-ID: 3F382A02.6090900@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Patch applied, with a few minor changes to work correctly under jdk1.2
and 1.3.

thanks,
--Barry

Oliver Jowett wrote:
> This patch rearranges how tests are built and run from build.xml:
>
> + Make all testsuites (jdbc2, jdbc2.optional, jdbc3) independent
> i.e. they run only their own tests and not those of earlier
> versions.
>
> + Run all applicable testsuites for the configured JDBC version,
> e.g. run jdbc2, jdbc2.optional, and jdbc3 if we are configured
> for JDBC3. The rationale is that the JDBC2 tests should work
> on JDBC2 *or any later version*.
>
> + Use Ant's <junit> task instead of running a JUnit UI. This cleans
> up the buildfile and produces somewhat nicer output than the text-ui.
> As Ant doesn't try to find the task class until the containing target
> is run, and we conditionalize running the test task on the
> presence of both JUnit and the JUnit task, this shouldn't cause
> errors if the task isn't present.
>
> + Merge the various per-version test targets into a single target with
> conditional <test> elements.
>
> + Use a separate builddir for the tests to help isolate them from the
> driver. Build a new postgresql-tests.jar jarfile containing just the tests.
>
> + Run the tests using the actual driver jarfile (and test jarfile)
> rather than whatever's in builddir. This should help make sure that you
> are testing the actual driver that will be used. One sideeffect of this
> is that PSQLException can find its resource bundle when running tests now
> (previously it couldn't as srcdir was not in the test classpath).
>
> I've tested this against Ant 1.5.3 and a 1.4 JDK, with and without JUnit and
> ant-optional (for the JUnit task) present. I don't have the resources to
> test other JDKs or Ant versions at the moment.
>
> -O
>
>
> ------------------------------------------------------------------------
>
> Index: src/interfaces/jdbc/build.xml
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/build.xml,v
> retrieving revision 1.32
> diff -u -c -r1.32 build.xml
> *** src/interfaces/jdbc/build.xml 27 Feb 2003 05:45:43 -0000 1.32
> --- src/interfaces/jdbc/build.xml 20 Jul 2003 07:56:59 -0000
> ***************
> *** 49,64 ****
> </condition>
> <available property="datasource" classname="javax.sql.DataSource"/>
> <available property="ssl" classname="javax.net.ssl.SSLSocketFactory"/>
> ! <available property="junit" classname="junit.framework.Test" />
> <condition property="jdbc2tests">
> <and>
> ! <isset property="jdbc2"/>
> <isset property="junit"/>
> </and>
> </condition>
> <condition property="jdbc2optionaltests">
> <and>
> ! <isset property="jdbc2"/>
> <isset property="datasource"/>
> <isset property="junit"/>
> </and>
> --- 49,71 ----
> </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.task" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
> <condition property="jdbc2tests">
> <and>
> ! <or>
> ! <isset property="jdbc2"/>
> ! <isset property="jdbc3"/>
> ! </or>
> <isset property="junit"/>
> </and>
> </condition>
> <condition property="jdbc2optionaltests">
> <and>
> ! <or>
> ! <isset property="jdbc2"/>
> ! <isset property="jdbc3"/>
> ! </or>
> <isset property="datasource"/>
> <isset property="junit"/>
> </and>
> ***************
> *** 83,89 ****
> <jar jarfile="${jardir}/postgresql.jar" whenempty="fail">
> <fileset dir="${builddir}">
> <include name="${package}/**/*.class" />
> - <exclude name="${package}/test/**" />
> </fileset>
>
> <fileset dir="${srcdir}">
> --- 90,95 ----
> ***************
> *** 108,113 ****
> --- 114,121 ----
> <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
> <include name="${package}/**" />
>
> + <exclude name="${package}/test/**" />
> +
> <exclude name="${package}/jdbc1/**" unless="jdbc1"/>
> <exclude name="${package}/jdbc2/**" unless="jdbc2"/>
> <exclude name="${package}/jdbc3/**" unless="jdbc3"/>
> ***************
> *** 274,335 ****
> <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" />
> -
>
> ! <target name="test" depends="testjdbc2,testjdbc2optional,testjdbc3">
> ! </target>
>
> - <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>
> -
> - <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}" />
> ! </classpath>
> ! </java>
> </target>
>
> - <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 path="${java.class.path}" />
> </classpath>
> - </java>
> - </target>
>
>
> </project>
> --- 282,331 ----
> <property name="username" value="test" />
> <!-- Password must be something. Doesn't matter if trust is used! -->
> <property name="password" value="password" />
>
> ! <!-- 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. -->
> !
> ! <!-- 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/**" />
> !
> ! <exclude name="${package}/test/jdbc2/**" unless="jdbc2tests"/>
> ! <exclude name="${package}/test/jdbc2/optional/**" unless="jdbc2optionaltests" />
> ! <exclude name="${package}/test/jdbc3/**" unless="jdbc3tests"/>
>
> <classpath>
> ! <pathelement location="${jardir}/postgresql.jar"/>
> </classpath>
> </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"/>
>
> <sysproperty key="database" value="${database}" />
> <sysproperty key="username" value="${username}" />
> <sysproperty key="password" value="${password}" />
> +
> <classpath>
> ! <pathelement location="${jardir}/postgresql.jar" />
> ! <pathelement location="${jardir}/postgresql-tests.jar" />
> <pathelement path="${java.class.path}" />
> </classpath>
>
> + <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: src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java,v
> retrieving revision 1.3
> diff -u -c -r1.3 Jdbc3TestSuite.java
> *** src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java 25 Sep 2002 07:01:31 -0000 1.3
> --- src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java 20 Jul 2003 07:56:59 -0000
> ***************
> *** 14,20 ****
> 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);
> --- 14,19 ----
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message zhan yi 2003-08-12 02:11:16 parser: parse error at or near "-"
Previous Message Barry Lind 2003-08-11 21:34:09 Re: patch: fix exceptions from ResultSet.getArray()