Apache Solr open-source search software
LUCENE-885: include contribs in 'ant test' ... includes fixes for several contribs to make tests run cleanly regardless of what working directory they are run in
Chris M. Hostettercb38e0c06c50
diff --git a/CHANGES.txt b/CHANGES.txtindex ad155dbf1ad..260641050e9 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -229,6 +229,11 @@ Build1. LUCENE-802: Added LICENSE.TXT and NOTICE.TXT to Lucene jars.(Steven Parkes via Michael Busch)+ 2. LUCENE-885: "ant test" now includes all contrib tests. The new+ "ant test-core" target can be used to run only the Core (non+ contrib) tests.+ (Chris Hostetter)+======================= Release 2.1.0 2007-02-14 =======================Changes in runtime behaviordiff --git a/build.xml b/build.xmlindex 862c39750d2..12af8a72c45 100644--- a/build.xml+++ b/build.xml@@ -71,6 +71,13 @@</rmic></target>+ <target name="test-core" depends="common.test"+ description="Runs unit tests for the core Lucene code"+ />+ <target name="test" depends="test-core, test-contrib"+ description="Runs all unit tests"+ />+<!-- ================================================================== --><!-- J A R --><!-- ================================================================== -->@@ -342,8 +349,9 @@<macrodef name="contrib-crawl"><attribute name="target" default=""/>+ <attribute name="failonerror" default="true"/><sequential>- <subant target="@{target}" failonerror="false">+ <subant target="@{target}" failonerror="@{failonerror}"><fileset dir="."includes="contrib/*/build.xml"/>@@ -356,7 +364,19 @@</target><target name="test-contrib" depends="compile-test">- <contrib-crawl target="test"/>+ <!-- don't fail on error, instead check for flag file so we run+ all the tests possible and can "ant generate-test-reports"+ for all of them+ -->+ <contrib-crawl target="test" failonerror="false"/>+ <available property="contribs.failed" file="junitfailed.flag">+ <filepath>+ <dirset dir="${build.dir}/contrib/">+ <include name="**/test/" />+ </dirset>+ </filepath>+ </available>+ <fail if="contribs.failed">Contrib tests failed!</fail></target><macrodef name="invoke-javadoc">diff --git a/common-build.xml b/common-build.xmlindex 57a5972450d..5f113511144 100644--- a/common-build.xml+++ b/common-build.xml@@ -194,6 +194,12 @@<sysproperty key="tempDir" file="${build.dir}/test"/><sysproperty key="java.io.tmpdir" file="${build.dir}/test"/>+ <!-- set as a system property so contrib testss can have a fixed root+ to reference file paths from, and "ant test" can work from+ anywhere.+ -->+ <sysproperty key="lucene.common.dir" file="${common.dir}" />+<!-- contrib/ant IndexTaskTest needs these two system properties --><sysproperty key="docs.dir" file="src/test"/><sysproperty key="index.dir" file="${build.dir}/test/index"/>@@ -210,8 +216,13 @@<fileset dir="src/test" includes="**/${testcase}.java"/></batchtest></junit>-+ <!-- create this file, then if we don't fail, delete it -->+ <!-- this meme makes it easy to tell if contribs have failed later -->+ <echo file="${build.dir}/test/junitfailed.flag">MAYBE</echo><fail if="tests.failed">Tests failed!</fail>+ <!-- life would be easier if echo had an 'if' attribute like fail -->+ <delete file="${build.dir}/test/junitfailed.flag" />+</target><!--@@ -259,8 +270,11 @@<target name="generate-test-reports" description="Generates test reports"><mkdir dir="${junit.reports}"/><junitreport todir="${junit.output.dir}">- <fileset dir="${junit.output.dir}">- <include name="TEST-*.xml"/>+ <!-- this fileset let's the task work for individual contribs,+ as well as the project as a whole+ -->+ <fileset dir="${build.dir}">+ <include name="**/test/TEST-*.xml"/></fileset><report format="frames" todir="${junit.reports}"/></junitreport>diff --git a/contrib/contrib-build.xml b/contrib/contrib-build.xmlindex 0d796e7ea2a..0e8cbcd2d26 100644--- a/contrib/contrib-build.xml+++ b/contrib/contrib-build.xml@@ -18,6 +18,7 @@<path id="test.classpath"><path refid="classpath"/>+ <pathelement location="../../build/classes/test/"/><pathelement location="${junit.jar}"/><pathelement location="${build.dir}/classes/java"/></path>diff --git a/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java b/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.javaindex 106095663f3..8ebd3074925 100644--- a/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java+++ b/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java@@ -48,7 +48,7 @@ import com.sleepycat.je.Transaction;* @author Aaron Donovan*/public class JEStoreTest extends TestCase {- protected File dbHome = new File("index");+ protected File dbHome = new File(System.getProperty("java.io.tmpdir"),"index");protected Environment env;diff --git a/contrib/db/bdb/build.xml b/contrib/db/bdb/build.xmlindex dccfd907c7a..fbed78cf2a9 100644--- a/contrib/db/bdb/build.xml+++ b/contrib/db/bdb/build.xml@@ -28,6 +28,33 @@dest="lib/db-${db.version}.jar" /></target>+ <target name="sanity-load-lib" depends="compile-test">+ <java classname="org.apache.lucene.store.db.SanityLoadLibrary"+ classpathref="junit.classpath"+ fork="true"+ failonerror="false"+ logError="false"+ outputproperty="sanity-load-lib-error"+ />+ <condition property="no-bdb-lib" value="true">+ <and>+ <isset property="sanity-load-lib-error"/>+ <not>+ <equals arg1="${sanity-load-lib-error}" arg2="" trim="true" />+ </not>+ </and>+ </condition>+ </target>++ <target name="warn-no-lib" if="no-bdb-lib">+ <echo>Unit Tests Skipped: Could not sanity check Native Library</echo>+ </target>+ <target name="test" depends="sanity-load-lib,warn-no-lib"+ unless="no-bdb-lib">+ <antcall target="common.test" inheritAll="true" inheritRefs="true" />+ </target>+<target name="check-and-get-db-jar" depends="get-db-jar" /><target name="init" depends="common.init,check-and-get-db-jar" />+</project>diff --git a/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java b/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.javaindex c324eeac479..0bf041b7eb8 100644--- a/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java+++ b/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java@@ -45,7 +45,7 @@ import org.apache.lucene.store.IndexOutput;* @author Andi Vajda*/public class DbStoreTest extends TestCase {- protected File dbHome = new File("index");+ protected File dbHome = new File(System.getProperty("java.io.tmpdir"),"index");protected Environment env;protected Database index, blocks;diff --git a/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java b/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.javanew file mode 100644index 00000000000..a887fab24f6--- /dev/null+++ b/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java@@ -0,0 +1,36 @@+package org.apache.lucene.store.db;++/**+ * 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.+ */++import com.sleepycat.db.EnvironmentConfig;+import com.sleepycat.db.Environment;++/**+ * Simple sanity testing application to verify that the underlying+ * native library can be loaded cleanly.+ *+ * For use in the build.xml of this contrib, to determine if tests+ * should be skipped.+ */+public class SanityLoadLibrary {+ public static void main(String[] ignored) throws Exception {+ EnvironmentConfig envConfig = EnvironmentConfig.DEFAULT;+ envConfig.setAllowCreate(false);+ Environment env = new Environment(null, envConfig);+ }+}diff --git a/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java b/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.javaindex 0b34eaac7c4..92a0c9b1f1f 100644--- a/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java+++ b/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java@@ -39,8 +39,9 @@ import com.google.gdata.util.ParseException;**/public class TestGDataEntityBuilder extends TestCase {- private static File incomingFeed = new File("src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingFeed.xml");- private static File incomingEntry = new File("src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingEntry.xml");+ private static String fileDir = System.getProperty("lucene.common.dir", null);+ private static File incomingFeed = new File(fileDir, "contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingFeed.xml");+ private static File incomingEntry = new File(fileDir, "contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingEntry.xml");private static String feedTitleFromXML = "Simon Willnauer";private static String entrySummaryFromXML = "When: 2006-12-23 to 2006-12-31 America/Los_Angeles";private static GDataServerRegistry reg = GDataServerRegistry.getRegistry();diff --git a/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java b/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.javaindex 5a725e1794d..91820c8eaee 100644--- a/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java+++ b/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java@@ -57,7 +57,8 @@ public class TestAbstractFeedHandler extends TestCase {private AdminService adminService = null;private ServiceFactoryStub stub;private String serviceName = StorageStub.SERVICE_TYPE_RETURN;- private static File incomingFeed = new File("src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingFeed.xml");+ private static String fileDir = System.getProperty("lucene.common.dir", null);+ private static File incomingFeed = new File(fileDir, "contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestEntityBuilderIncomingFeed.xml");BufferedReader reader;static{diff --git a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.javaindex ed1819159fc..cb489fc967b 100644--- a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java+++ b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java@@ -209,19 +209,24 @@ public class MemoryIndexTest extends TestCase {new MemoryIndexTest().run(args);}-// public void setUp() { }+ /* all files will be open relative to this */+ public String fileDir;+ public void setUp() {+ fileDir = System.getProperty("lucene.common.dir", null);+ }+// public void tearDown() {}public void testMany() throws Throwable {String[] files = listFiles(new String[] {"*.txt", "*.html", "*.xml", "xdocs/*.xml","src/java/test/org/apache/lucene/queryParser/*.java",- "src/java/org/apache/lucene/index/memory/*.java",+ "contrib/memory/src/java/org/apache/lucene/index/memory/*.java",});System.out.println("files = " + java.util.Arrays.asList(files));String[] xargs = new String[] {"1", "1", "memram",- "@src/test/org/apache/lucene/index/memory/testqueries.txt",+ "@contrib/memory/src/test/org/apache/lucene/index/memory/testqueries.txt",};String[] args = new String[xargs.length + files.length];System.arraycopy(xargs, 0, args, 0, xargs.length);@@ -247,7 +252,7 @@ public class MemoryIndexTest extends TestCase {if (args.length > ++k) {String arg = args[k];if (arg.startsWith("@"))- queries = readLines(new File(arg.substring(1)));+ queries = readLines(new File(fileDir, arg.substring(1)));elsequeries = new String[] { arg };}@@ -522,4 +527,4 @@ public class MemoryIndexTest extends TestCase {}}-}\ No newline at end of file+}diff --git a/contrib/xml-query-parser/build.xml b/contrib/xml-query-parser/build.xmlindex e271b193eb1..6d73a94016a 100644--- a/contrib/xml-query-parser/build.xml+++ b/contrib/xml-query-parser/build.xml@@ -1,6 +1,6 @@<?xml version="1.0"?>-<project name="xml-query-parser" default="buildParser">+<project name="xml-query-parser" default="default"><description>XML query parser@@ -8,7 +8,8 @@<import file="../contrib-build.xml"/>- <property name="queries.jar" location="../../build/contrib/queries/lucene-queries-${version}.jar"/>+ <property name="queries.jar" location="${common.dir}/build/contrib/queries/lucene-queries-${version}.jar"/>+ <available property="queries.jar.present" type="file" file="${queries.jar}"/><path id="classpath"><pathelement path="${lucene.jar}"/>@@ -17,9 +18,9 @@</path>- <target name="buildParser" depends="buildQueries,default" />+ <target name="compile-core" depends="build-queries, common.compile-core" />- <target name="buildQueries" >+ <target name="build-queries" unless="queries.jar.present"><echo>XML Parser building dependency ${queries.jar}</echo><ant antfile="../queries/build.xml" target="default" inheritall="false"/></target>