summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksei Zotov <azotcsit@gmail.com>2021-11-15 18:20:17 +0400
committerJaikiran Pai <jaikiran@apache.org>2021-11-16 18:07:57 +0530
commitc8bc470774001278b809f69898bc43e98933ff15 (patch)
tree61ca7ca328b8f36c27a758ad20364340c3bc86ca
parent5db51cebc334034162450a8fdf70ddebf1b2085e (diff)
downloadant-c8bc470774001278b809f69898bc43e98933ff15.tar.gz
junitlauncher - Support extension attribute for listeners
This closes #168 pull request at github.com/apache/ant
-rw-r--r--CONTRIBUTORS1
-rw-r--r--WHATSNEW5
-rw-r--r--contributors.xml4
-rw-r--r--manual/Tasks/junitlauncher.html13
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java16
6 files changed, 37 insertions, 10 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index d0e684eef..5cbe06118 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -8,6 +8,7 @@ Adam Sotona
Adrian Nistor
Adrien Grand
Aleksandr Ishutin
+Aleksei Zotov
Alex
Alex Rosen
Alexander Grund
diff --git a/WHATSNEW b/WHATSNEW
index 293f4862e..49c78152c 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -8,6 +8,11 @@ Other changes:
repackaged Jakarta Mail package rather than javax Mail.
Github Pull Request #161
+* The "listener" element in the junitlauncher task now supports
+ an "extension" attribute to control the filename extension
+ of the generated output file from the listener.
+ Github Pull Request #168
+
Changes from Ant 1.10.11 TO Ant 1.10.12
=======================================
diff --git a/contributors.xml b/contributors.xml
index 74329cff6..574f45e4f 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -63,6 +63,10 @@
<last>Ishutin</last>
</name>
<name>
+ <first>Aleksei</first>
+ <last>Zotov</last>
+ </name>
+ <name>
<first>Alex</first>
<last></last>
</name>
diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html
index f8899bb72..0f20648e4 100644
--- a/manual/Tasks/junitlauncher.html
+++ b/manual/Tasks/junitlauncher.html
@@ -354,7 +354,7 @@
If no value is specified for this attribute and the listener implements
the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
then the file name will be defaulted to and will be of the
- form <code>TEST-<i>testname</i>.<i>formatter-specific-extension</i></code>
+ form <code>TEST-<i>testname</i>.<i>extension</i></code>
(ex: <samp>TEST-org.myapp.SomeTest.xml</samp> for the <q>legacy-xml</q> type
formatter)
</p>
@@ -367,6 +367,13 @@
<td>No</td>
</tr>
<tr>
+ <td>extension</td>
+ <td>Extension to append to the output filename.
+ <p><em>Since Ant 1.10.13</em></p>
+ </td>
+ <td>No; defaults to <q>xml</q> for the <q>legacy-xml</q> formatter and to <q>txt</q> for the rest</td>
+ </tr>
+ <tr>
<td>outputDir</td>
<td>Directory into which to create the output of the listener.
<p><em>Since Ant 1.10.6</em></p>
@@ -406,10 +413,10 @@
<tr>
<td>useLegacyReportingName</td>
<td>Set to true, if the test identifiers reported by this listener should use legacy (JUnit4
- style) names. Else set to false. Defaults to true.
+ style) names. Else set to false.
<p><em>Since Ant 1.10.10</em></p>
</td>
- <td>No</td>
+ <td>No; defaults to <q>true</q></td>
</tr>
</table>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
index 7bd65e3b0..00b76df8a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
@@ -282,13 +282,7 @@ public class LauncherSupport {
final StringBuilder sb = new StringBuilder("TEST-");
sb.append(testRequest.getName() == null ? "unknown" : testRequest.getName());
sb.append(".");
- final String suffix;
- if ("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter".equals(listener.getClassName())) {
- suffix = "xml";
- } else {
- suffix = "txt";
- }
- sb.append(suffix);
+ sb.append(listener.getExtension());
filename = sb.toString();
}
if (listener.getOutputDir() != null) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java
index ce9fdee1d..52479a9c9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java
@@ -49,6 +49,7 @@ public class ListenerDefinition {
private String unlessProperty;
private String className;
private String resultFile;
+ private String extension = "txt";
private boolean sendSysOut;
private boolean sendSysErr;
private String outputDir;
@@ -94,6 +95,7 @@ public class ListenerDefinition {
}
case LEGACY_XML: {
this.setClassName("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter");
+ this.setExtension("xml");
break;
}
}
@@ -107,6 +109,20 @@ public class ListenerDefinition {
return this.resultFile;
}
+ /**
+ * Sets the output file extension for this listener.
+ *
+ * @param extension file extension to use
+ * @since Ant 1.10.13
+ */
+ public void setExtension(String extension) {
+ this.extension = extension;
+ }
+
+ public String getExtension() {
+ return extension;
+ }
+
public void setSendSysOut(final boolean sendSysOut) {
this.sendSysOut = sendSysOut;
}