You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2002/04/03 10:15:30 UTC
cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs AntTest.java
bodewig 02/04/03 00:15:30
Modified: src/etc/testcases/taskdefs ant.xml
src/main/org/apache/tools/ant/taskdefs Ant.java
src/testcases/org/apache/tools/ant/taskdefs AntTest.java
Log:
Add testcase for <ant>'s logfile placement, fix NPE in <ant>.
If <ant> should ignore the dir attribute, we only have to change the
locations of test3.log and test4.log.
Revision Changes Path
1.6 +16 -0 jakarta-ant/src/etc/testcases/taskdefs/ant.xml
Index: ant.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/ant.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ant.xml 13 Dec 2001 11:56:25 -0000 1.5
+++ ant.xml 3 Apr 2002 08:15:30 -0000 1.6
@@ -2,6 +2,13 @@
<project name="ant-test" basedir="." default="test1">
+ <target name="cleanup">
+ <delete file="test1.log" />
+ <delete file="test2.log" />
+ <delete file="ant/test3.log" />
+ <delete file="ant/test4.log" />
+ </target>
+
<target name="all" depends="test1,test2,test3,test4"/>
<target name="test1">
@@ -67,4 +74,13 @@
</ant>
</target>
+ <target name="testLogfilePlacement">
+ <ant antfile="ant.xml" target="dummy" output="test1.log"
+ inheritall="false" />
+ <ant antfile="ant.xml" target="dummy" output="test2.log" />
+ <ant antfile="ant.xml" target="dummy" output="test3.log"
+ inheritall="false" dir="ant" />
+ <ant antfile="ant.xml" target="dummy" output="test4.log"
+ dir="ant" />
+ </target>
</project>
1.45 +4 -3 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
Index: Ant.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- Ant.java 1 Apr 2002 05:41:30 -0000 1.44
+++ Ant.java 3 Apr 2002 08:15:30 -0000 1.45
@@ -105,7 +105,6 @@
/** the output */
private String output = null;
- private String outfile = null;
/** should we inherit properties from the parent ? */
private boolean inheritAll = true;
@@ -175,9 +174,11 @@
}
if (output != null) {
+ File outfile = null;
if (dir != null) {
- File file = FileUtils.newFileUtils().resolveFile(dir, output);
- outfile = file.getAbsolutePath();
+ outfile = FileUtils.newFileUtils().resolveFile(dir, output);
+ } else {
+ outfile = getProject().resolveFile(output);
}
try {
PrintStream out = new PrintStream(new FileOutputStream(outfile));
1.9 +33 -4 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java
Index: AntTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AntTest.java 10 Jan 2002 10:13:12 -0000 1.8
+++ AntTest.java 3 Apr 2002 08:15:30 -0000 1.9
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,7 @@
/**
* @author Nico Seessle <ni...@seessle.de>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public class AntTest extends BuildFileTest {
@@ -78,6 +78,10 @@
configureProject("src/etc/testcases/taskdefs/ant.xml");
}
+ public void tearDown() {
+ executeTarget("cleanup");
+ }
+
public void test1() {
expectBuildException("test1", "recursive call");
}
@@ -213,6 +217,26 @@
project.removeBuildListener(rc);
}
+ public void testLogfilePlacement() {
+ File[] logFiles = new File[] {
+ getProject().resolveFile("test1.log"),
+ getProject().resolveFile("test2.log"),
+ getProject().resolveFile("ant/test3.log"),
+ getProject().resolveFile("ant/test3.log")
+ };
+ for (int i=0; i<logFiles.length; i++) {
+ assertTrue(logFiles[i].getName()+" doesn\'t exist",
+ !logFiles[i].exists());
+ }
+
+ executeTarget("testLogfilePlacement");
+
+ for (int i=0; i<logFiles.length; i++) {
+ assertTrue(logFiles[i].getName()+" exists",
+ logFiles[i].exists());
+ }
+ }
+
private class BasedirChecker implements BuildListener {
private String[] expectedBasedirs;
private int calls = 0;
@@ -232,8 +256,13 @@
public void targetStarted(BuildEvent event) {
if (error == null) {
try {
- assertEquals(expectedBasedirs[calls++],
- event.getProject().getBaseDir().getAbsolutePath());
+ if (calls == expectedBasedirs.length) {
+ assertEquals("cleanup",
+ event.getTarget().getName());
+ } else {
+ assertEquals(expectedBasedirs[calls++],
+ event.getProject().getBaseDir().getAbsolutePath());
+ }
} catch (AssertionFailedError e) {
error = e;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>