A first shot at an Ant script for running the tests using the classes that were built by Maven.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@553337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
336
build-testing.xml
Normal file
336
build-testing.xml
Normal file
@@ -0,0 +1,336 @@
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<!--
|
||||
- Ant file for running tests for commons-logging.
|
||||
-
|
||||
- Quick build instructions:
|
||||
- * mvn package
|
||||
- * ant getlibs
|
||||
- * cp build.properties.sample build.properties
|
||||
- * ant -lib lib/junit-3.8.1.jar -f build-testing.xml test
|
||||
-
|
||||
- Note that this build file uses the optional <junit> task. While the
|
||||
- task "adapter" class comes by default with ant 1.6+, the junit libraries
|
||||
- (3.8.1 or later) are also required to be made available to ant. This
|
||||
- requires that you do one of the following:
|
||||
- * create directory ~/.ant/lib and place the junit jar there
|
||||
- * put the junit jar in $ANT_HOME/lib
|
||||
- * run ant as "ant -lib path-to-junit-jar"
|
||||
- * put the junit jar in $CLASSPATH
|
||||
-
|
||||
- Note when running these test before a JCL release it is strongly
|
||||
- recommended that a 1.2 JVM is used.
|
||||
-
|
||||
- $Id: build.xml 491210 2006-12-30 11:15:59Z dennisl $
|
||||
-->
|
||||
|
||||
<project name="Logging" default="all" basedir=".">
|
||||
|
||||
|
||||
<!-- ========== Initialize Properties ===================================== -->
|
||||
|
||||
|
||||
<property file="build.properties"/> <!-- Component local -->
|
||||
<property file="../build.properties"/> <!-- Commons local -->
|
||||
<property file="${user.home}/build.properties"/> <!-- User local -->
|
||||
|
||||
|
||||
<!-- ========== External Dependencies ===================================== -->
|
||||
|
||||
|
||||
<!-- The directories corresponding to your necessary dependencies -->
|
||||
<property name="junit.home" value="/usr/local/junit3.5"/>
|
||||
<property name="jakarta.home" value="../.."/>
|
||||
|
||||
<!--
|
||||
- The names of the unit tests to run. By default all tests are run, but
|
||||
- this can be overridden from the command line by something like:
|
||||
- ant -Dtestmatch=**/FooTestCase test
|
||||
-->
|
||||
<property name="testmatch" value="**/*TestCase"/>
|
||||
|
||||
|
||||
<!-- ========== Derived Values ============================================ -->
|
||||
|
||||
|
||||
<!-- The locations of necessary jar files -->
|
||||
<property name="junit.jar" value="junit-3.8.1.jar"/>
|
||||
<property name="log4j12.jar" value="log4j-1.2.12.jar"/>
|
||||
<property name="log4j13.jar" value="log4j-1.3.0.jar"/>
|
||||
<property name="logkit.jar" value="logkit-1.0.1.jar"/>
|
||||
<property name="avalon-framework.jar" value="avalon-framework-4.1.3.jar"/>
|
||||
<property name="servletapi.jar" value="servletapi-2.3.jar"/>
|
||||
|
||||
|
||||
<!-- ========== Component Declarations ==================================== -->
|
||||
|
||||
|
||||
<!-- The name of this component -->
|
||||
<property name="component.name" value="logging"/>
|
||||
|
||||
<!-- The primary package name of this component -->
|
||||
<property name="component.package" value="org.apache.commons.logging"/>
|
||||
|
||||
<!-- The title of this component -->
|
||||
<property name="component.title" value="Logging Wrapper Library"/>
|
||||
|
||||
<!-- The current version number of this component -->
|
||||
<property name="component.version" value="1.1.1-SNAPSHOT"/>
|
||||
|
||||
<!-- The base directory for compilation targets -->
|
||||
<property name="build.home" value="${basedir}/target"/>
|
||||
|
||||
<!-- The base directory for component configuration files -->
|
||||
<property name="conf.home" value="src/conf"/>
|
||||
|
||||
<!-- jar names -->
|
||||
<property name="core.jar.name" value="commons-${component.name}-${component.version}.jar"/>
|
||||
<property name="api.jar.name" value="commons-${component.name}-api-${component.version}.jar"/>
|
||||
<property name="adapters.jar.name" value="commons-${component.name}-adapters-${component.version}.jar"/>
|
||||
<property name="src.ide.name" value="commons-${component.name}-${component.version}-ide.zip"/>
|
||||
|
||||
<!-- Construct compile classpath -->
|
||||
<path id="compile.classpath">
|
||||
<pathelement location="${build.home}/classes"/>
|
||||
<pathelement location="${junit.jar}"/>
|
||||
<pathelement location="${logkit.jar}"/>
|
||||
<pathelement location="${avalon-framework.jar}"/>
|
||||
<pathelement location="${servletapi.jar}"/>
|
||||
</path>
|
||||
|
||||
|
||||
<!-- ========== Test Execution Defaults =================================== -->
|
||||
|
||||
|
||||
<!--
|
||||
- Construct unit test classpath (generic tests).
|
||||
-
|
||||
- Note that unit tests that use the PathableTestSuite approach don't need
|
||||
- any of this (except junit). However unit tests that don't use PathableTestSuite
|
||||
- to configure their classpath will need the basic classes to be provided
|
||||
- via this mechanism.
|
||||
-->
|
||||
<path id="test.classpath">
|
||||
<pathelement location="${build.home}/classes"/>
|
||||
<pathelement location="${build.home}/test-classes"/>
|
||||
<pathelement location="${junit.jar}"/>
|
||||
<pathelement location="${logkit.jar}"/>
|
||||
<pathelement location="${avalon-framework.jar}"/>
|
||||
<pathelement location="${conf.home}"/>
|
||||
<pathelement location="${servletapi.jar}"/>
|
||||
</path>
|
||||
|
||||
<!-- Construct unit test classpath (Log4J tests) -->
|
||||
<path id="test.classpath.log4j13">
|
||||
<pathelement location="${build.home}/classes"/>
|
||||
<pathelement location="${build.home}/test-classes"/>
|
||||
<pathelement location="${junit.jar}"/>
|
||||
<pathelement location="${log4j13.jar}"/>
|
||||
</path>
|
||||
|
||||
<!-- Construct unit test classpath (Log4J tests) -->
|
||||
<path id="test.classpath.log4j12">
|
||||
<pathelement location="${build.home}/classes"/>
|
||||
<pathelement location="${build.home}/test-classes"/>
|
||||
<pathelement location="${junit.jar}"/>
|
||||
<pathelement location="${log4j12.jar}"/>
|
||||
</path>
|
||||
|
||||
<!-- Should all tests fail if one does? -->
|
||||
<property name="test.failonerror" value="true"/>
|
||||
|
||||
<!-- The test runner to execute -->
|
||||
<property name="test.runner" value="junit.textui.TestRunner"/>
|
||||
|
||||
<!-- libs to pass to the tests -->
|
||||
<property name="test.sysprops.testclasses" value="${build.home}/test-classes"/>
|
||||
<property name="test.sysprops.log4j12" value="${log4j12.jar}"/>
|
||||
<property name="test.sysprops.log4j13" value="${log4j13.jar}"/>
|
||||
<property name="test.sysprops.logkit" value="${logkit.jar}"/>
|
||||
<property name="test.sysprops.servlet-api" value="${servletapi.jar}"/>
|
||||
<property name="test.sysprops.commons-logging" value="${build.home}/${core.jar.name}"/>
|
||||
<property name="test.sysprops.commons-logging-api" value="${build.home}/${api.jar.name}"/>
|
||||
<property name="test.sysprops.commons-logging-adapters" value="${build.home}/${adapters.jar.name}"/>
|
||||
<propertyset id="test-lib-props">
|
||||
<propertyref prefix="test.sysprops."/>
|
||||
<mapper type="glob" from="test.sysprops.*" to="*"/>
|
||||
</propertyset>
|
||||
|
||||
<!-- ========== Executable Targets ======================================== -->
|
||||
|
||||
|
||||
<!--
|
||||
- Running this target will download all the necessary dependencies into the "lib" subdirectory.
|
||||
-->
|
||||
<property name="getlibs.base" value="http://repo1.maven.org/maven"/>
|
||||
<target name="getlibs">
|
||||
<mkdir dir="lib"/>
|
||||
<get dest="lib/junit-3.8.1.jar" src="${getlibs.base}/junit/jars/junit-3.8.1.jar"/>
|
||||
<get dest="lib/logkit-1.0.1.jar" src="${getlibs.base}/logkit/jars/logkit-1.0.1.jar"/>
|
||||
<get dest="lib/avalon-framework-4.1.3.jar" src="${getlibs.base}/avalon-framework/jars/avalon-framework-4.1.3.jar"/>
|
||||
<get dest="lib/log4j-1.2.12.jar" src="${getlibs.base}/log4j/jars/log4j-1.2.12.jar"/>
|
||||
<get dest="lib/servletapi-2.3.jar" src="${getlibs.base}/servletapi/jars/servletapi-2.3.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="init"
|
||||
description="Initialize and evaluate conditionals">
|
||||
<echo message="-------- ${component.title} ${component.version} --------"/>
|
||||
<filter token="name" value="${component.name}"/>
|
||||
<filter token="package" value="${component.package}"/>
|
||||
<filter token="version" value="${component.version}"/>
|
||||
</target>
|
||||
|
||||
<target name="prepare" depends="init"
|
||||
description="Prepare build directory">
|
||||
|
||||
<echo>
|
||||
Log4j12: ${log4j12.jar}
|
||||
<!-- Note: log4j13 support is not available in the 1.1 release. -->
|
||||
<!--Log4j13: ${log4j13.jar}-->
|
||||
LogKit: ${logkit.jar}
|
||||
Avalon-Framework: ${avalon-framework.jar}
|
||||
</echo>
|
||||
|
||||
<mkdir dir="${build.home}"/>
|
||||
<mkdir dir="${build.home}/classes"/>
|
||||
<mkdir dir="${build.home}/conf"/>
|
||||
<mkdir dir="${build.home}/tests"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name='discovery' depends='init'>
|
||||
<available property="jdk.1.4.present"
|
||||
classname="java.util.logging.Logger"/>
|
||||
|
||||
<available property="logkit.present"
|
||||
classpathref="compile.classpath"
|
||||
classname="org.apache.log.Logger"/>
|
||||
|
||||
<available property="avalon-framework.present"
|
||||
classpathref="compile.classpath"
|
||||
classname="org.apache.avalon.framework.logger.Logger"/>
|
||||
|
||||
<available file="${log4j12.jar}" property="log4j12.present"/>
|
||||
<available file="${log4j13.jar}" property="log4j13.present"/>
|
||||
<available file="${build.home}/docs" property="maven.generated.docs.present"/>
|
||||
</target>
|
||||
|
||||
<target name="log4j12-test-warning" unless='log4j12.jar' depends='init,discovery'>
|
||||
<echo>
|
||||
*** WARNING ***
|
||||
Log4J 1.2.x Jar not found: Cannot execute 1.2.x tests
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<target name="show-lib-presence">
|
||||
<echo message="jdk.1.4.present=${jdk.1.4.present}"/>
|
||||
<echo message="log4j12.present=${log4j12.present}"/>
|
||||
<!-- Note: log4j13 support is not available in the 1.1 release. -->
|
||||
<!--<echo message="log4j13.present=${log4j13.present}"/>-->
|
||||
<echo message="logkit.present=${logkit.present}"/>
|
||||
<echo message="avalon-framework.present=${avalon-framework.present}"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="all" depends="test"
|
||||
description="Test all components"/>
|
||||
|
||||
|
||||
<!-- ========== Unit Test Targets ========================================= -->
|
||||
|
||||
|
||||
<!--
|
||||
- Target to run all unit tests.
|
||||
-
|
||||
- The batchtest task auto-detects what tests are available without
|
||||
- any need to define TestSuite objects in the code to compose
|
||||
- sets of tests to be run.
|
||||
-
|
||||
- Details of the unit test results for each TestCase will appear in
|
||||
- a file in directory ${build.home}/test-reports, together with any
|
||||
- output to stdout or stderr generated by the test code.
|
||||
-
|
||||
- If you're having problems running this target due to the use of
|
||||
- the "junit" task below, see the comments at the head of this file.
|
||||
-
|
||||
- Individual tests (or subsets of tests) can be run by doing
|
||||
- ant -Dtestmatch=**/FooTestCase testall
|
||||
-->
|
||||
|
||||
<target name="test" depends="log4j12-test-warning"
|
||||
description="Run all unit tests">
|
||||
<echo message="Test output can be found in directory ${build.home}/test-reports."/>
|
||||
<delete dir="${build.home}/test-reports"/>
|
||||
<mkdir dir="${build.home}/test-reports"/>
|
||||
|
||||
<echo message="executing tests [${testmatch}.java]"/>
|
||||
<!--
|
||||
- Note that the fork/forkmode settings define default behaviour for tests.
|
||||
- The <test> and <batchtest> tags can override these settings if needed.
|
||||
- The default settings cause a single VM to be created in which all of
|
||||
- the tests are then run.
|
||||
-->
|
||||
<junit printsummary="off" showoutput="no" fork="yes" forkmode="once" failureproperty="test.failure">
|
||||
<!-- plain output to file; brief output to console. -->
|
||||
<formatter type="plain"/>
|
||||
<formatter usefile="false" type="brief"/>
|
||||
|
||||
<!--
|
||||
- Provide a set of properties pointing to the logging libs for
|
||||
- the use of the PathableClassLoader class used by some unit tests.
|
||||
-->
|
||||
<syspropertyset refid="test-lib-props"/>
|
||||
<classpath refid="test.classpath"/>
|
||||
|
||||
<!--
|
||||
- Uncomment this to enable logging diagnostics for tests
|
||||
- <jvmarg value="-Dorg.apache.commons.logging.diagnostics.dest=STDERR"/>
|
||||
-->
|
||||
|
||||
<!--
|
||||
- Auto-detect the tests to run. Checking the ${build.home}/tests
|
||||
- directory for .class files rather than the src/test directory
|
||||
- for .java files means that when we run the tests on platforms
|
||||
- where some components (eg jdk14 logging) is not available,
|
||||
- just ensuring the tests are skipped from the compile will
|
||||
- also cause them to be skipped from the testing.
|
||||
-
|
||||
- This does introduce the danger that if tests accidentally
|
||||
- fail to compile then we won't notice it here. However that
|
||||
- should have been reported earlier anyway.
|
||||
-->
|
||||
<batchtest todir="${build.home}/test-reports">
|
||||
<fileset dir="${build.home}/test-classes">
|
||||
<include name="${testmatch}.class"/>
|
||||
<!--
|
||||
- Exclude the jdk14 tests because we are running these tests on
|
||||
- a jvm < 1.4
|
||||
-->
|
||||
<exclude name="org/apache/commons/logging/jdk14/*"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
|
||||
<fail if="test.failure">
|
||||
One or more unit tests failed.
|
||||
</fail>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
Reference in New Issue
Block a user