Github user jaikiran commented on a diff in the pull request: https://github.com/apache/ant/pull/60#discussion_r168983118 --- Diff: src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java --- @@ -0,0 +1,139 @@ +package org.apache.tools.ant.taskdefs.optional.junitlauncher; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.junit.platform.engine.TestSource; +import org.junit.platform.engine.support.descriptor.ClassSource; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + +/** + * Contains some common behaviour that's used by our internal {@link TestResultFormatter}s + */ +abstract class AbstractJUnitResultFormatter implements TestResultFormatter { + + protected static String NEW_LINE = System.getProperty("line.separator"); + protected Path sysOutFilePath; + protected Path sysErrFilePath; + protected Task task; + + private OutputStream sysOutStream; + private OutputStream sysErrStream; + + @Override + public void sysOutAvailable(final byte[] data) { + if (this.sysOutStream == null) { + try { + this.sysOutFilePath = Files.createTempFile(null, "sysout"); + this.sysOutFilePath.toFile().deleteOnExit(); + this.sysOutStream = Files.newOutputStream(this.sysOutFilePath); + } catch (IOException e) { + handleException(e); + return; + } + } + try { + this.sysOutStream.write(data); + } catch (IOException e) { + handleException(e); + return; + } + } + + @Override + public void sysErrAvailable(final byte[] data) { + if (this.sysErrStream == null) { + try { + this.sysErrFilePath = Files.createTempFile(null, "syserr"); + this.sysErrFilePath.toFile().deleteOnExit(); + this.sysErrStream = Files.newOutputStream(this.sysOutFilePath); --- End diff -- Indeed :) Fixed.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org For additional commands, e-mail: dev-h...@ant.apache.org