You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by ho...@apache.org on 2007/05/30 09:18:32 UTC

svn commit: r542769 - in /lucene/java/trunk: ./ contrib/ contrib/db/bdb-je/src/test/org/apache/lucene/store/je/ contrib/db/bdb/ contrib/db/bdb/src/test/org/apache/lucene/store/db/ contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/re...

Author: hossman
Date: Wed May 30 00:18:29 2007
New Revision: 542769

URL: http://svn.apache.org/viewvc?view=rev&rev=542769
Log:
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

Added:
    lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java   (with props)
Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/build.xml
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/contrib/contrib-build.xml
    lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
    lucene/java/trunk/contrib/db/bdb/build.xml
    lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
    lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java
    lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java
    lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
    lucene/java/trunk/contrib/xml-query-parser/build.xml

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed May 30 00:18:29 2007
@@ -229,6 +229,11 @@
  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

Modified: lucene/java/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/build.xml?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/build.xml (original)
+++ lucene/java/trunk/build.xml Wed May 30 00:18:29 2007
@@ -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">

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Wed May 30 00:18:29 2007
@@ -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>

Modified: lucene/java/trunk/contrib/contrib-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/contrib-build.xml?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/contrib-build.xml (original)
+++ lucene/java/trunk/contrib/contrib-build.xml Wed May 30 00:18:29 2007
@@ -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>

Modified: lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java (original)
+++ lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java Wed May 30 00:18:29 2007
@@ -48,7 +48,7 @@
  * @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;
 

Modified: lucene/java/trunk/contrib/db/bdb/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb/build.xml?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/db/bdb/build.xml (original)
+++ lucene/java/trunk/contrib/db/bdb/build.xml Wed May 30 00:18:29 2007
@@ -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>

Modified: lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java (original)
+++ lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java Wed May 30 00:18:29 2007
@@ -45,7 +45,7 @@
  * @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;
     

Added: lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java?view=auto&rev=542769
==============================================================================
--- lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java (added)
+++ lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java Wed May 30 00:18:29 2007
@@ -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);
+  }
+}

Propchange: lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/SanityLoadLibrary.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/server/registry/TestGDataEntityBuilder.java Wed May 30 00:18:29 2007
@@ -39,8 +39,9 @@
  * 
  */ 
 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(); 

Modified: lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/core/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java Wed May 30 00:18:29 2007
@@ -57,7 +57,8 @@
     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{
         

Modified: lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java (original)
+++ lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java Wed May 30 00:18:29 2007
@@ -209,19 +209,24 @@
     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 @@
     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 @@
     }
   }
   
-}
\ No newline at end of file
+}

Modified: lucene/java/trunk/contrib/xml-query-parser/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/build.xml?view=diff&rev=542769&r1=542768&r2=542769
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/build.xml (original)
+++ lucene/java/trunk/contrib/xml-query-parser/build.xml Wed May 30 00:18:29 2007
@@ -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>