Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Ant构建脚本中的JUnit尝试删除.svn目录,但失败_Java_Ant_Junit - Fatal编程技术网

Java Ant构建脚本中的JUnit尝试删除.svn目录,但失败

Java Ant构建脚本中的JUnit尝试删除.svn目录,但失败,java,ant,junit,Java,Ant,Junit,我下面是一个实用的项目自动化的例子。我在Windows7上运行,并从本地Subversion repo中提取该项目。在项目的基本目录中运行ant时,出现以下错误[junit]无法删除.svn。以下是命令的完整输出: Buildfile: S:\CruiseControl\builds\dms\checkout\dms\build.xml prepare: [mkdir] Created dir: S:\CruiseControl\builds\dms\checkout\dms\buil

我下面是一个实用的项目自动化的例子。我在Windows7上运行,并从本地Subversion repo中提取该项目。在项目的基本目录中运行
ant
时,出现以下错误
[junit]无法删除.svn
。以下是命令的完整输出:

Buildfile: S:\CruiseControl\builds\dms\checkout\dms\build.xml

prepare:
    [mkdir] Created dir: S:\CruiseControl\builds\dms\checkout\dms\build\prod
    [mkdir] Created dir: S:\CruiseControl\builds\dms\checkout\dms\build\test

compile:
    [javac] Compiling 5 source files to S:\CruiseControl\builds\dms\checkout\dms\build\prod

compile-tests:
    [javac] Compiling 7 source files to S:\CruiseControl\builds\dms\checkout\dms\build\test

test:
    [junit] Testsuite: com.pragprog.dms.DocumentTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.065 sec
    [junit] 
    [junit] Testsuite: com.pragprog.dms.SearchTest
    [junit] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.015 sec
    [junit] 
    [junit] Testcase: testTitleSearch(com.pragprog.dms.SearchTest): Caused an ERROR
    [junit] couldn't delete .svn
    [junit] java.io.IOException: couldn't delete .svn
    [junit]     at org.apache.lucene.store.FSDirectory.create(FSDirectory.java:166)
    [junit]     at org.apache.lucene.store.FSDirectory.<init>(FSDirectory.java:151)
    [junit]     at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:132)
    [junit]     at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:160)
    [junit]     at com.pragprog.dms.Indexer.index(Unknown Source)
    [junit]     at com.pragprog.dms.SearchTest.setUp(Unknown Source)
    [junit] 
    [junit] 
    [junit] Testcase: testContentSearch(com.pragprog.dms.SearchTest):   Caused an ERROR
    [junit] couldn't delete .svn
    [junit] java.io.IOException: couldn't delete .svn
    [junit]     at org.apache.lucene.store.FSDirectory.create(FSDirectory.java:166)
    [junit]     at org.apache.lucene.store.FSDirectory.<init>(FSDirectory.java:151)
    [junit]     at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:132)
    [junit]     at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:160)
    [junit]     at com.pragprog.dms.Indexer.index(Unknown Source)
    [junit]     at com.pragprog.dms.SearchTest.setUp(Unknown Source)
    [junit] 
    [junit] 

BUILD FAILED
S:\CruiseControl\builds\dms\checkout\dms\build.xml:33: Test com.pragprog.dms.SearchTest failed

Total time: 0 seconds
Buildfile:S:\CruiseControl\builds\dms\checkout\dms\build.xml
准备:
[mkdir]已创建目录:S:\CruiseControl\builds\dms\checkout\dms\build\prod
[mkdir]已创建目录:S:\CruiseControl\builds\dms\checkout\dms\build\test
汇编:
[javac]将5个源文件编译为S:\CruiseControl\builds\dms\checkout\dms\build\prod
编译测试:
[javac]将7个源文件编译为S:\CruiseControl\builds\dms\checkout\dms\build\test
测试:
[junit]测试套件:com.pragprog.dms.DocumentTest
[junit]测试运行:2,失败:0,错误:0,所用时间:0.065秒
[少年]
[junit]Testsuite:com.pragprog.dms.SearchTest
[junit]测试运行:2,失败:0,错误:2,运行时间:0.015秒
[少年]
[junit]Testcase:testTitleSearch(com.pragprog.dms.SearchTest):导致错误
[junit]无法删除.svn
[junit]java.io.IOException:无法删除.svn
[junit]位于org.apache.lucene.store.FSDirectory.create(FSDirectory.java:166)
[junit]位于org.apache.lucene.store.FSDirectory.(FSDirectory.java:151)
[junit]位于org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:132)
[junit]位于org.apache.lucene.index.IndexWriter(IndexWriter.java:160)
[junit]位于com.pragprog.dms.Indexer.index(未知源)
[junit]位于com.pragprog.dms.SearchTest.setUp(未知源)
[少年]
[少年]
[junit]Testcase:testContentSearch(com.pragprog.dms.SearchTest):导致错误
[junit]无法删除.svn
[junit]java.io.IOException:无法删除.svn
[junit]位于org.apache.lucene.store.FSDirectory.create(FSDirectory.java:166)
[junit]位于org.apache.lucene.store.FSDirectory.(FSDirectory.java:151)
[junit]位于org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:132)
[junit]位于org.apache.lucene.index.IndexWriter(IndexWriter.java:160)
[junit]位于com.pragprog.dms.Indexer.index(未知源)
[junit]位于com.pragprog.dms.SearchTest.setUp(未知源)
[少年]
[少年]
构建失败
S:\CruiseControl\builds\dms\checkout\dms\build.xml:33:Test com.pragprog.dms.SearchTest失败
总时间:0秒
以及build.xml文件:

<project name="dms" default="compile" basedir=".">
    <property name="build.dir" location="build" />
    <property name="build.prod.dir" location="${build.dir}/prod" />
    <property name="build.test.dir" location="${build.dir}/test" />
    <property name="doc.dir" location="doc" />
    <property name="index.dir" location="index" />
    <property name="src.dir" location="src" />
    <property name="test.dir" location="test" />
    <property name="vendor.lib.dir" location="vendor/lib" />
    <path id="project.classpath">
        <pathelement location="${build.prod.dir}" />
        <pathelement location="${build.test.dir}" />
        <fileset dir="${vendor.lib.dir}">
            <include name="*.jar" />
        </fileset>
    </path>
    <target name="prepare">
        <mkdir dir="${build.prod.dir}" />
        <mkdir dir="${build.test.dir}" />
    </target>
    <target name="compile" depends="prepare">
        <javac srcdir="${src.dir}" destdir="${build.prod.dir}" includeantruntime="false">
            <classpath refid="project.classpath" />
        </javac>
    </target>
    <target name="compile-tests" depends="compile">
        <javac srcdir="${test.dir}" destdir="${build.test.dir}" includeantruntime="false">
            <classpath refid="project.classpath" />
            <compilerarg value="-Xlint:unchecked" />
        </javac>
    </target>
    <target name="test" depends="compile-tests">
        <junit haltonfailure="true">
            <classpath refid="project.classpath" />
            <formatter type="brief" usefile="false" />
            <batchtest>
                <fileset dir="${build.test.dir}" includes="**/*Test.class" />
            </batchtest>
            <sysproperty key="doc.dir" value="${doc.dir}" />
            <sysproperty key="index.dir" value="${index.dir}" />
        </junit>
    </target>
    <target name="clean">
        <delete dir="${build.dir}" />
    </target>
</project>


为什么JUnit试图删除.svn目录?它甚至试图删除哪一个?为什么它没有这样做?

看起来
com.pragprog.dms.SearchTest
中的测试用例
testTitleSearch
失败了。同样的情况也会发生在
testContentSearch
中。他们可能在出发前试图打扫房间。我猜您在本地克隆测试用例时无意中将其暂存目录置于版本控制之下。

我以前经常使用
-N[--非递归]
,但我知道现在首选
--depth
。啊,原来它使用项目基本目录中的索引/文件夹作为暂存文件夹。构建脚本现在执行得很好。最后,我使用Process Explorer来确定哪个文件夹是有问题的。不过,这似乎不是一种非常有效的做事方式。有没有更好的方法来解决这个问题,比如说。。。有可能让JUnit吐出完整的路径吗?我不确定JUnit,但较旧版本的
ant
可能需要这样做。