From 4a9c1fbf6e6aac7b25e5f29a21dbbdb18c5d057f Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 19 Sep 2000 16:25:40 +0000 Subject: [PATCH] Added dir attribute to and documentation for the one of . git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268012 13f79535-47bb-0310-9956-ffa450edef68 --- docs/index.html | 6 ++++++ docs/junit.html | 6 ++++++ .../taskdefs/optional/junit/JUnitTask.java | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/docs/index.html b/docs/index.html index 87cfb8ff6..86a057b5d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2334,6 +2334,12 @@ the one that is currently running Ant.

returncode other than 0. Only available if fork is true. No + + dir + The directory to invoke the VM in. (ignored if + fork is disabled) + No +

Parameters specified as nested elements

arg and jvmarg

diff --git a/docs/junit.html b/docs/junit.html index c17d761db..80a0d31d7 100644 --- a/docs/junit.html +++ b/docs/junit.html @@ -64,6 +64,12 @@ elements.

Ignored if fork is disabled. No, default "java" + + dir + The directory to invoke the VM in. (ignored if + fork is disabled) + No +

Nested Elements

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 680acc594..b675f1006 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -91,6 +91,7 @@ public class JUnitTask extends Task { private Vector tests = new Vector(); private Vector batchTests = new Vector(); private Vector formatters = new Vector(); + private File dir = null; private Integer timeout = null; private boolean summary = false; @@ -161,6 +162,15 @@ public class JUnitTask extends Task { formatters.addElement(fe); } + /** + * The directory to invoke the VM in. + * + *

Ignored if fork=false. + */ + public void setDir(File dir) { + this.dir = dir; + } + /** * Creates a new JUnitRunner and enables fork of a new Java VM. */ @@ -201,6 +211,12 @@ public class JUnitTask extends Task { int exitValue = JUnitTestRunner.ERRORS; if (!test.getFork()) { + + if (dir != null) { + log("dir attribute ignored if running in the same VM", + Project.MSG_WARN); + } + JUnitTestRunner runner = new JUnitTestRunner(test, test.getHaltonerror(), test.getHaltonfailure()); @@ -283,6 +299,10 @@ public class JUnitTask extends Task { Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), createWatchdog()); execute.setCommandline(cmd.getCommandline()); + if (dir != null) { + execute.setWorkingDirectory(dir); + } + log("Executing: "+cmd.toString(), Project.MSG_VERBOSE); try { exitValue = execute.execute();