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

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@542769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2007-05-30 07:18:29 +00:00
parent 8caf74c26e
commit cb38e0c06c
12 changed files with 130 additions and 19 deletions

View File

@ -229,6 +229,11 @@ Build
1. 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 behavior

View File

@ -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">

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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>

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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{

View File

@ -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)));
else
queries = new String[] { arg };
}
@ -522,4 +527,4 @@ public class MemoryIndexTest extends TestCase {
}
}
}
}

View File

@ -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>