You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2020/05/05 13:33:16 UTC
[ant] 02/03: make junitlauncher use ant.tmpdir as well
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
commit 041b058c7bf10a94d56db3ca9dba38cf90ab9943
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Tue May 5 15:01:39 2020 +0200
make junitlauncher use ant.tmpdir as well
---
manual/Tasks/junitlauncher.html | 4 ++++
.../optional/junitlauncher/AbstractJUnitResultFormatter.java | 10 ++++++----
.../optional/junitlauncher/confined/JUnitLauncherTask.java | 4 ++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html
index 25d9fcc..ec14e03 100644
--- a/manual/Tasks/junitlauncher.html
+++ b/manual/Tasks/junitlauncher.html
@@ -43,6 +43,10 @@
case is nor does it execute the tests itself.
</p>
<p>
+ This task captures testoutput and configuration data inside of
+ the <a href="../running.html#tmpdir">temporary directory</a>.
+</p>
+<p>
<strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for
more information.
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
index dc9847d..22a11e0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
@@ -53,7 +53,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
@Override
public void sysOutAvailable(final byte[] data) {
if (this.sysOutStore == null) {
- this.sysOutStore = new SysOutErrContentStore(true);
+ this.sysOutStore = new SysOutErrContentStore(context, true);
}
try {
this.sysOutStore.store(data);
@@ -65,7 +65,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
@Override
public void sysErrAvailable(final byte[] data) {
if (this.sysErrStore == null) {
- this.sysErrStore = new SysOutErrContentStore(false);
+ this.sysErrStore = new SysOutErrContentStore(context, false);
}
try {
this.sysErrStore.store(data);
@@ -212,13 +212,15 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
}
};
+ private final TestExecutionContext context;
private final String tmpFileSuffix;
private ByteBuffer inMemoryStore = ByteBuffer.allocate(DEFAULT_CAPACITY_IN_BYTES);
private boolean usingFileStore = false;
private Path filePath;
private FileOutputStream fileOutputStream;
- private SysOutErrContentStore(final boolean isSysOut) {
+ private SysOutErrContentStore(final TestExecutionContext context, final boolean isSysOut) {
+ this.context = context;
this.tmpFileSuffix = isSysOut ? ".sysout" : ".syserr";
}
@@ -261,7 +263,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
private FileOutputStream createFileStore() throws IOException {
this.filePath = FileUtils.getFileUtils()
- .createTempFile(null, this.tmpFileSuffix, null, true, true)
+ .createTempFile(context.getProject().orElse(null), null, this.tmpFileSuffix, null, true, true)
.toPath();
return new FileOutputStream(this.filePath.toFile());
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
index 0d16ed0..fa28844 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -226,7 +226,7 @@ public class JUnitLauncherTask extends Task {
private java.nio.file.Path dumpProjectProperties() throws IOException {
final java.nio.file.Path propsPath = FileUtils.getFileUtils()
- .createTempFile(null, "properties", null, true, true)
+ .createTempFile(getProject(), null, "properties", null, true, true)
.toPath();
final Hashtable<String, Object> props = this.getProject().getProperties();
final Properties projProperties = new Properties();
@@ -367,7 +367,7 @@ public class JUnitLauncherTask extends Task {
private java.nio.file.Path newLaunchDefinitionXml() {
return FileUtils.getFileUtils()
- .createTempFile(null, ".xml", null, true, true)
+ .createTempFile(getProject(), null, ".xml", null, true, true)
.toPath();
}