heads up, if you have an old checkout you might want to run 'ant clean'.

this is because the Solr Junit formatter was moved here to lucene, but
I don't think Solr yet detects dependencies being uptodate correctly.

On Fri, Mar 26, 2010 at 5:55 PM,  <rm...@apache.org> wrote:
> Author: rmuir
> Date: Fri Mar 26 21:55:57 2010
> New Revision: 928069
>
> URL: http://svn.apache.org/viewvc?rev=928069&view=rev
> Log:
> LUCENE-1709: Parallelize Tests
>
> Added:
>    
> lucene/dev/trunk/lucene/backwards/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>      - copied, changed from r927697, 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java
>    
> lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>      - copied, changed from r927697, 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java
> Removed:
>    
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java
> Modified:
>    lucene/dev/trunk/lucene/build.xml
>    lucene/dev/trunk/lucene/common-build.xml
>    
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
>    
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
>    lucene/dev/trunk/solr/build.xml
>    lucene/dev/trunk/solr/common-build.xml
>
> Copied: 
> lucene/dev/trunk/lucene/backwards/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>  (from r927697, 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java)
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/backwards/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java?p2=lucene/dev/trunk/lucene/backwards/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java&p1=lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java&r1=927697&r2=928069&rev=928069&view=diff
> ==============================================================================
> --- 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java 
> (original)
> +++ 
> lucene/dev/trunk/lucene/backwards/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>  Fri Mar 26 21:55:57 2010
> @@ -16,8 +16,9 @@
>  *
>  */
>
> -package org.apache.solr;
> +package org.apache.lucene.util;
>
> +import java.io.File;
>  import java.io.IOException;
>  import java.io.OutputStream;
>  import java.text.NumberFormat;
> @@ -25,6 +26,8 @@ import java.text.NumberFormat;
>  import junit.framework.AssertionFailedError;
>  import junit.framework.Test;
>
> +import org.apache.lucene.store.LockReleaseFailedException;
> +import org.apache.lucene.store.NativeFSLockFactory;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner;
> @@ -37,9 +40,11 @@ import org.apache.tools.ant.util.StringU
>  * At this point, the output is written at once in synchronized fashion.
>  * This way tests can run in parallel without interleaving output.
>  */
> -public class SolrJUnitResultFormatter implements JUnitResultFormatter {
> +public class LuceneJUnitResultFormatter implements JUnitResultFormatter {
>   private static final double ONE_SECOND = 1000.0;
>
> +  private NativeFSLockFactory lockFactory;
> +
>   /** Where to write the log to. */
>   private OutputStream out;
>
> @@ -55,8 +60,21 @@ public class SolrJUnitResultFormatter im
>   /** Buffer output until the end of the test */
>   private StringBuilder sb;
>
> +  private org.apache.lucene.store.Lock lock;
> +
>   /** Constructor for SolrJUnitResultFormatter. */
> -  public SolrJUnitResultFormatter() {
> +  public LuceneJUnitResultFormatter() {
> +    File lockDir = new File(System.getProperty("java.io.tmpdir"), 
> "lucene_junit_lock");
> +    lockDir.mkdirs();
> +    if(!lockDir.exists()) {
> +      throw new RuntimeException("Could not make Lock directory:" + lockDir);
> +    }
> +    try {
> +      lockFactory = new NativeFSLockFactory(lockDir);
> +      lock = lockFactory.makeLock("junit_lock");
> +    } catch (IOException e) {
> +      throw new RuntimeException(e);
> +    }
>     sb = new StringBuilder();
>   }
>
> @@ -135,8 +153,17 @@ public class SolrJUnitResultFormatter im
>
>     if (out != null) {
>       try {
> -        out.write(sb.toString().getBytes());
> -        out.flush();
> +        lock.obtain(5000);
> +        try {
> +          out.write(sb.toString().getBytes());
> +          out.flush();
> +        } finally {
> +          try {
> +            lock.release();
> +          } catch(LockReleaseFailedException e) {
> +            // well lets pretend its released anyway
> +          }
> +        }
>       } catch (IOException e) {
>         throw new RuntimeException("unable to write results", e);
>       } finally {
> @@ -227,3 +254,4 @@ public class SolrJUnitResultFormatter im
>     sb.append(StringUtils.LINE_SEP);
>   }
>  }
> +
>
> Modified: lucene/dev/trunk/lucene/build.xml
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/build.xml?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- lucene/dev/trunk/lucene/build.xml (original)
> +++ lucene/dev/trunk/lucene/build.xml Fri Mar 26 21:55:57 2010
> @@ -102,7 +102,7 @@
>  The source distribution does not contain sources of the previous Lucene Java 
> version.</echo>
>   </target>
>
> -  <target name="test-backwards" depends="compile-core, jar-core, 
> test-backwards-message"
> +  <target name="compile-backwards" depends="compile-core, jar-core, 
> test-backwards-message"
>        description="Runs tests of a previous Lucene version." 
> if="backwards.available">
>     <sequential>
>       <mkdir dir="${build.dir.backwards}"/>
> @@ -120,14 +120,64 @@ The source distribution does not contain
>       <compile-test-macro srcdir="${backwards.dir}/src/test" 
> destdir="${build.dir.backwards}/classes/test"
>                   test.classpath="backwards.test.compile.classpath" 
> javac.source="${javac.source.backwards}" 
> javac.target="${javac.target.backwards}"/>
>
> -      <!-- run branch tests against trunk jar -->
> -      <test-macro dataDir="${backwards.dir}/src/test"
> -              tempDir="${build.dir.backwards}/test"
> -              junit.classpath="backwards.junit.classpath"
> -              junit.output.dir="${junit.output.dir.backwards}" />
> +
>     </sequential>
>   </target>
> -
> +
> +  <target name="test-backwards" depends="compile-backwards, 
> junit-backwards-mkdir, junit-backwards-sequential, junit-backwards-parallel"/>
> +
> +  <target name="junit-backwards-mkdir">
> +       <mkdir dir="${build.dir.backwards}/test"/>
> +  </target>
> +
> +  <macrodef name="backwards-test-macro">
> +       <attribute name="pattern" default=""/>
> +       <sequential>
> +         <!-- run branch tests against trunk jar -->
> +      <test-macro
> +       dataDir="${backwards.dir}/src/test"
> +       tempDir="${build.dir.backwards}/test"
> +       junit.classpath="backwards.junit.classpath"
> +       junit.output.dir="${junit.output.dir.backwards}"
> +        pattern="@{pattern}" />
> +       </sequential>
> +  </macrodef>
> +
> +  <target name="junit-backwards-sequential" if="runsequential">
> +    <backwards-test-macro/>
> +  </target>
> +
> +  <target name="junit-backwards-parallel" unless="runsequential">
> +    <parallel threadsPerProcessor="2">
> +     <backwards-test-macro pattern="A"/>
> +     <backwards-test-macro pattern="B"/>
> +     <backwards-test-macro pattern="C"/>
> +     <backwards-test-macro pattern="D"/>
> +     <backwards-test-macro pattern="E"/>
> +     <backwards-test-macro pattern="F"/>
> +     <backwards-test-macro pattern="G"/>
> +     <backwards-test-macro pattern="H"/>
> +     <backwards-test-macro pattern="I"/>
> +     <backwards-test-macro pattern="J"/>
> +     <backwards-test-macro pattern="K"/>
> +     <backwards-test-macro pattern="L"/>
> +     <backwards-test-macro pattern="M"/>
> +     <backwards-test-macro pattern="N"/>
> +     <backwards-test-macro pattern="O"/>
> +     <backwards-test-macro pattern="P"/>
> +     <backwards-test-macro pattern="Q"/>
> +     <backwards-test-macro pattern="R"/>
> +     <backwards-test-macro pattern="S"/>
> +     <backwards-test-macro pattern="T"/>
> +     <backwards-test-macro pattern="U"/>
> +     <backwards-test-macro pattern="V"/>
> +     <backwards-test-macro pattern="W"/>
> +     <backwards-test-macro pattern="X"/>
> +     <backwards-test-macro pattern="Y"/>
> +     <backwards-test-macro pattern="Z"/>
> +    </parallel>
> +  </target>
> +
>   <!-- ================================================================== -->
>   <!-- J A R                                                              -->
>   <!-- ================================================================== -->
> @@ -684,24 +734,7 @@ The source distribution does not contain
>   </target>
>
>   <target name="test-contrib" depends="build-contrib">
> -    <!-- 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.
> -
> -         Because of this, we depend on "build-contrib" even though the
> -         Individual contrib "test" targets probably have the
> -         neccessary dependencies.  If they fail to compile, we won't
> -         know about it.
> -     -->
> -    <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>
> +    <contrib-crawl target="test" failonerror="true"/>
>   </target>
>
>   <!-- Macro for building checksum files -->
>
> Modified: lucene/dev/trunk/lucene/common-build.xml
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/common-build.xml?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- lucene/dev/trunk/lucene/common-build.xml (original)
> +++ lucene/dev/trunk/lucene/common-build.xml Fri Mar 26 21:55:57 2010
> @@ -99,8 +99,14 @@
>   <property name="junit.output.dir.backwards" 
> location="${build.dir.backwards}/test"/>
>   <property name="junit.reports" location="${build.dir}/test/reports"/>
>   <property name="junit.reports.backwards" 
> location="${build.dir.backwards}/test/reports"/>
> -  <property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
>   <property name="junit.excludes" value=""/>
> +  <property name="junit.details.formatter" 
> value="org.apache.lucene.util.LuceneJUnitResultFormatter"/>
> +  <condition property="runsequential">
> +    <or>
> +      <isset property="testcase"/>
> +      <isset property="sequential-tests"/>
> +    </or>
> +  </condition>
>
>   <property name="manifest.file" location="${common.dir}/build/MANIFEST.MF"/>
>
> @@ -387,9 +393,9 @@
>   <macrodef name="test-macro" description="Executes junit tests.">
>        <attribute name="junit.output.dir" default="${junit.output.dir}"/>
>        <attribute name="junit.classpath" default="junit.classpath"/>
> -       <attribute name="dataDir"/>
> -       <attribute name="tempDir"/>
> -       <element name="contrib-settings" optional="yes"/>
> +       <attribute name="dataDir" default="src/test"/>
> +       <attribute name="tempDir" default="${build.dir}/test"/>
> +       <attribute name="pattern" default=""/>
>
>     <sequential>
>            <condition property="runall">
> @@ -399,7 +405,10 @@
>                <isset property="testpackageroot" />
>              </or></not>
>            </condition>
> -               <mkdir dir="@{junit.output.dir}"/>
> +           <!-- <mkdir dir="@{tempDir}/@{pattern}"/>
> +           This is very loud and obnoxious. abuse touch instead for a 
> "quiet" mkdir
> +           -->
> +       <touch file="@{tempDir}/@{pattern}/quiet.ant" verbose="false" 
> mkdirs="true"/>
>            <junit printsummary="off" haltonfailure="no" maxmemory="512M"
>              errorProperty="tests.failed" failureProperty="tests.failed" 
> forkmode="perBatch" dir=".">
>              <classpath refid="@{junit.classpath}"/>
> @@ -413,56 +422,85 @@
>              <sysproperty key="tests.verbose" value="${tests.verbose}"/>
>
>              <!-- TODO: create propertyset for test properties, so each 
> project can have its own set -->
> -             <sysproperty key="tempDir" file="@{tempDir}"/>
> -             <sysproperty key="java.io.tmpdir" file="@{tempDir}"/>
> +             <sysproperty key="tempDir" file="@{tempDir}/@{pattern}"/>
> +
>              <sysproperty key="lucene.version" value="${dev.version}"/>
>
> -                 <contrib-settings />
> +          <!-- set as a system property so contrib tests 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"/>
> +
> +          <!-- contrib/benchmark uses this system property to locate docs 
> data and defined tasks -->
> +          <sysproperty key="tasks.dir" 
> file="${build.dir}/classes/java/org/apache/lucene/benchmark/byTask/tasks"/>
> +          <sysproperty key="benchmark.work.dir" 
> file="@{tempDir}/@{pattern}"/>
>
>              <formatter type="xml"/>
> -             <formatter type="brief" usefile="false"/>
> +             <formatter classname="${junit.details.formatter}" 
> usefile="false"/>
>              <batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
> -               <fileset dir="@{dataDir}" includes="${junit.includes}" 
> excludes="${junit.excludes}"/>
> +               <fileset dir="@{dataDir}" 
> includes="**/t...@{pattern}*.java,**/@{pattern}*Test.java" 
> excludes="${junit.excludes}"/>
>              </batchtest>
>              <batchtest fork="yes" todir="@{junit.output.dir}" 
> if="testpackage">
> -               <fileset dir="@{dataDir}" 
> includes="**/${testpackage}/**/Test*.java,**/${testpackage}/**/*Test.java" 
> excludes="${junit.excludes}"/>
> +               <fileset dir="@{dataDir}" 
> includes="**/${testpackage}/**/t...@{pattern}*.java,**/${testpackage}/**/@{pattern}*Test.java"
>  excludes="${junit.excludes}"/>
>              </batchtest>
>              <batchtest fork="yes" todir="@{junit.output.dir}" 
> if="testpackageroot">
> -               <fileset dir="@{dataDir}" 
> includes="**/${testpackageroot}/Test*.java,**/${testpackageroot}/*Test.java" 
> excludes="${junit.excludes}"/>
> +               <fileset dir="@{dataDir}" 
> includes="**/${testpackageroot}/t...@{pattern}*.java,**/${testpackageroot}/@{pattern}*Test.java"
>  excludes="${junit.excludes}"/>
>              </batchtest>
>              <batchtest fork="yes" todir="@{junit.output.dir}" if="testcase">
>                <fileset dir="@{dataDir}" 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="@{junit.output.dir}/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="@{junit.output.dir}/junitfailed.flag" />
>        </sequential>
>   </macrodef>
>
> -  <target name="test" depends="compile-test" description="Runs unit tests">
> -    <test-macro dataDir="src/test" tempDir="${build.dir}/test">
> -       <contrib-settings>
> -             <!-- set as a system property so contrib tests 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"/>
> -
> -             <!-- contrib/benchmark uses this system property to locate docs 
> data and defined tasks -->
> -             <sysproperty key="tasks.dir" 
> file="${build.dir}/classes/java/org/apache/lucene/benchmark/byTask/tasks"/>
> -             <sysproperty key="benchmark.work.dir" 
> file="${common.dir}/contrib/benchmark/work"/>
> -         </contrib-settings>
> -    </test-macro>
> +  <target name="test" 
> depends="compile-test,junit-mkdir,junit-sequential,junit-parallel" 
> description="Runs unit tests"/>
> +
> +  <target name="junit-mkdir">
> +       <mkdir dir="${junit.output.dir}"/>
>   </target>
>
> +  <target name="junit-sequential" if="runsequential">
> +    <test-macro/>
> +  </target>
> +
> +  <target name="junit-parallel" unless="runsequential">
> +    <parallel threadsPerProcessor="2">
> +     <test-macro pattern="A"/>
> +     <test-macro pattern="B"/>
> +     <test-macro pattern="C"/>
> +     <test-macro pattern="D"/>
> +     <test-macro pattern="E"/>
> +     <test-macro pattern="F"/>
> +     <test-macro pattern="G"/>
> +     <test-macro pattern="H"/>
> +     <test-macro pattern="I"/>
> +     <test-macro pattern="J"/>
> +     <test-macro pattern="K"/>
> +     <test-macro pattern="L"/>
> +     <test-macro pattern="M"/>
> +     <test-macro pattern="N"/>
> +     <test-macro pattern="O"/>
> +     <test-macro pattern="P"/>
> +     <test-macro pattern="Q"/>
> +     <test-macro pattern="R"/>
> +     <test-macro pattern="S"/>
> +     <test-macro pattern="T"/>
> +     <test-macro pattern="U"/>
> +     <test-macro pattern="V"/>
> +     <test-macro pattern="W"/>
> +     <test-macro pattern="X"/>
> +     <test-macro pattern="Y"/>
> +     <test-macro pattern="Z"/>
> +    </parallel>
> +  </target>
> +
> +
>     <!--
>      If you want clover test code coverage, run this before the tests.  You 
> need clover.jar and the license in your ANT classspath and you need to 
> specify -Drun.clover=true on the command line.
>
>
> Modified: 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
>  (original)
> +++ 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
>  Fri Mar 26 21:55:57 2010
> @@ -19,10 +19,10 @@ package org.apache.lucene.benchmark;
>
>  import java.io.File;
>
> -import junit.framework.TestCase;
> +import org.apache.lucene.util.LuceneTestCase;
>
>  /** Base class for all Benchmark unit tests. */
> -public class BenchmarkTestCase extends TestCase {
> +public class BenchmarkTestCase extends LuceneTestCase {
>
>   private static final File workDir;
>
>
> Modified: 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
>  (original)
> +++ 
> lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
>  Fri Mar 26 21:55:57 2010
> @@ -24,6 +24,7 @@ import java.io.InputStream;
>  import java.io.InputStreamReader;
>  import java.io.PrintWriter;
>
> +import org.apache.lucene.benchmark.BenchmarkTestCase;
>  import org.apache.lucene.benchmark.byTask.TestPerfTasksLogic;
>  import org.apache.lucene.benchmark.quality.Judge;
>  import org.apache.lucene.benchmark.quality.QualityQuery;
> @@ -44,44 +45,30 @@ import org.apache.lucene.util.LuceneTest
>  * this test will not work correctly, as it does not dynamically
>  * generate its test trec topics/qrels!
>  */
> -public class TestQualityRun extends LuceneTestCase {
> +public class TestQualityRun extends BenchmarkTestCase {
>
> -  public TestQualityRun(String name) {
> -    super(name);
> -  }
> -
>   public void testTrecQuality() throws Exception {
>     // first create the partial reuters index
>     createReutersIndex();
>
> -    File workDir = new File(System.getProperty("benchmark.work.dir","work"));
> -    assertTrue("Bad workDir: "+workDir, workDir.exists()&& 
> workDir.isDirectory());
> -
>     int maxResults = 1000;
>     String docNameField = "doctitle"; // orig docID is in the linedoc format 
> title
>
>     PrintWriter logger = VERBOSE ? new PrintWriter(System.out,true) : null;
> -
> -    // <tests src dir> for topics/qrels files - 
> src/test/org/apache/lucene/benchmark/quality
> -    File srcTestDir = new File(new File(new File(new File(new File(
> -      new File(new File(workDir.getAbsoluteFile().getParentFile(),
> -        "src"),"test"),"org"),"apache"),"lucene"),"benchmark"),"quality");
> -
> +
>     // prepare topics
> -    File topicsFile = new File(srcTestDir, "trecTopics.txt");
> -    assertTrue("Bad topicsFile: "+topicsFile, topicsFile.exists()&& 
> topicsFile.isFile());
> +    InputStream topics = getClass().getResourceAsStream("trecTopics.txt");
>     TrecTopicsReader qReader = new TrecTopicsReader();
> -    QualityQuery qqs[] = qReader.readQueries(new BufferedReader(new 
> FileReader(topicsFile)));
> +    QualityQuery qqs[] = qReader.readQueries(new BufferedReader(new 
> InputStreamReader(topics, "UTF-8")));
>
>     // prepare judge
> -    File qrelsFile = new File(srcTestDir, "trecQRels.txt");
> -    assertTrue("Bad qrelsFile: "+qrelsFile, qrelsFile.exists()&& 
> qrelsFile.isFile());
> -    Judge judge = new TrecJudge(new BufferedReader(new 
> FileReader(qrelsFile)));
> +    InputStream qrels = getClass().getResourceAsStream("trecQRels.txt");
> +    Judge judge = new TrecJudge(new BufferedReader(new 
> InputStreamReader(qrels, "UTF-8")));
>
>     // validate topics & judgments match each other
>     judge.validateData(qqs, logger);
>
> -    IndexSearcher searcher = new IndexSearcher(FSDirectory.open(new 
> File(workDir,"index")), true);
> +    IndexSearcher searcher = new IndexSearcher(FSDirectory.open(new 
> File(getWorkDir(),"index")), true);
>
>     QualityQueryParser qqParser = new SimpleQQParser("title","body");
>     QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, 
> docNameField);
>
> Copied: 
> lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>  (from r927697, 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java)
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java&p1=lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java&r1=927697&r2=928069&rev=928069&view=diff
> ==============================================================================
> --- 
> lucene/dev/trunk/solr/src/test/org/apache/solr/SolrJUnitResultFormatter.java 
> (original)
> +++ 
> lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneJUnitResultFormatter.java
>  Fri Mar 26 21:55:57 2010
> @@ -16,8 +16,9 @@
>  *
>  */
>
> -package org.apache.solr;
> +package org.apache.lucene.util;
>
> +import java.io.File;
>  import java.io.IOException;
>  import java.io.OutputStream;
>  import java.text.NumberFormat;
> @@ -25,6 +26,8 @@ import java.text.NumberFormat;
>  import junit.framework.AssertionFailedError;
>  import junit.framework.Test;
>
> +import org.apache.lucene.store.LockReleaseFailedException;
> +import org.apache.lucene.store.NativeFSLockFactory;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
>  import org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner;
> @@ -37,9 +40,11 @@ import org.apache.tools.ant.util.StringU
>  * At this point, the output is written at once in synchronized fashion.
>  * This way tests can run in parallel without interleaving output.
>  */
> -public class SolrJUnitResultFormatter implements JUnitResultFormatter {
> +public class LuceneJUnitResultFormatter implements JUnitResultFormatter {
>   private static final double ONE_SECOND = 1000.0;
>
> +  private NativeFSLockFactory lockFactory;
> +
>   /** Where to write the log to. */
>   private OutputStream out;
>
> @@ -55,8 +60,21 @@ public class SolrJUnitResultFormatter im
>   /** Buffer output until the end of the test */
>   private StringBuilder sb;
>
> +  private org.apache.lucene.store.Lock lock;
> +
>   /** Constructor for SolrJUnitResultFormatter. */
> -  public SolrJUnitResultFormatter() {
> +  public LuceneJUnitResultFormatter() {
> +    File lockDir = new File(System.getProperty("java.io.tmpdir"), 
> "lucene_junit_lock");
> +    lockDir.mkdirs();
> +    if(!lockDir.exists()) {
> +      throw new RuntimeException("Could not make Lock directory:" + lockDir);
> +    }
> +    try {
> +      lockFactory = new NativeFSLockFactory(lockDir);
> +      lock = lockFactory.makeLock("junit_lock");
> +    } catch (IOException e) {
> +      throw new RuntimeException(e);
> +    }
>     sb = new StringBuilder();
>   }
>
> @@ -135,8 +153,17 @@ public class SolrJUnitResultFormatter im
>
>     if (out != null) {
>       try {
> -        out.write(sb.toString().getBytes());
> -        out.flush();
> +        lock.obtain(5000);
> +        try {
> +          out.write(sb.toString().getBytes());
> +          out.flush();
> +        } finally {
> +          try {
> +            lock.release();
> +          } catch(LockReleaseFailedException e) {
> +            // well lets pretend its released anyway
> +          }
> +        }
>       } catch (IOException e) {
>         throw new RuntimeException("unable to write results", e);
>       } finally {
> @@ -227,3 +254,4 @@ public class SolrJUnitResultFormatter im
>     sb.append(StringUtils.LINE_SEP);
>   }
>  }
> +
>
> Modified: lucene/dev/trunk/solr/build.xml
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/build.xml?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- lucene/dev/trunk/solr/build.xml (original)
> +++ lucene/dev/trunk/solr/build.xml Fri Mar 26 21:55:57 2010
> @@ -349,6 +349,7 @@
>     <pathelement location="${dest}/tests"/>
>     <!-- include the solrj classpath and jetty files included in example -->
>     <path refid="compile.classpath.solrj" />
> +    <pathelement location="${common-solr.dir}/../lucene/build/classes/test" 
> />  <!-- include some lucene test code -->
>     <pathelement path="${java.class.path}"/>
>   </path>
>
>
> Modified: lucene/dev/trunk/solr/common-build.xml
> URL: 
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/common-build.xml?rev=928069&r1=928068&r2=928069&view=diff
> ==============================================================================
> --- lucene/dev/trunk/solr/common-build.xml (original)
> +++ lucene/dev/trunk/solr/common-build.xml Fri Mar 26 21:55:57 2010
> @@ -103,7 +103,7 @@
>   <property name="junit.output.dir" 
> location="${common-solr.dir}/${dest}/test-results"/>
>   <property name="junit.reports" 
> location="${common-solr.dir}/${dest}/test-results/reports"/>
>   <property name="junit.formatter" value="plain"/>
> -  <property name="junit.details.formatter" 
> value="org.apache.solr.SolrJUnitResultFormatter"/>
> +  <property name="junit.details.formatter" 
> value="org.apache.lucene.util.LuceneJUnitResultFormatter"/>
>
>   <!-- Maven properties -->
>   <property name="maven.build.dir" value="${basedir}/build/maven"/>
>
>
>



-- 
Robert Muir
rcm...@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to