try to fix distsourcebuild error

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884785 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-12-25 01:42:10 +00:00
parent a0fa9e19b1
commit 6b6e96e07d
2 changed files with 12 additions and 6 deletions

View File

@ -1239,7 +1239,7 @@ under the License.
<length string="@{module2}" when="greater" length="0"/> <length string="@{module2}" when="greater" length="0"/>
</condition> </condition>
<delete file="build/status-as-tests-run.txt" failonerror="false"/> <delete file="@{outputDir}/status-as-tests-run.txt" failonerror="false"/>
<!-- As of 2018, JaCoCo is managing expectations and stay on Java 5 and therefore don't support junitlauncher --> <!-- As of 2018, JaCoCo is managing expectations and stay on Java 5 and therefore don't support junitlauncher -->
<!-- https://github.com/jacoco/jacoco/issues/673 ... m( --> <!-- https://github.com/jacoco/jacoco/issues/673 ... m( -->
@ -1255,6 +1255,7 @@ under the License.
<testclasses outputDir="@{outputDir}"> <testclasses outputDir="@{outputDir}">
<fork> <fork>
<sysproperty key="junit5.progress.file" value="@{outputDir}/status-as-tests-run.txt"/>
<syspropertyset refid="junit.properties"/> <syspropertyset refid="junit.properties"/>
<sysproperty key="java.io.tmpdir" value="${tempdir}"/> <sysproperty key="java.io.tmpdir" value="${tempdir}"/>
<jvmarg value="-Xmx@{heap}M"/> <jvmarg value="-Xmx@{heap}M"/>
@ -1279,14 +1280,15 @@ under the License.
<jvmarg line="--add-modules org.apache.poi.@{module2}" if:set="use_module2"/> <jvmarg line="--add-modules org.apache.poi.@{module2}" if:set="use_module2"/>
</fork> </fork>
<!-- can't use resultfile="status-as-tests-run.txt" here ... it's truncated with every test -->
<listener classname="Junit5Progress" outputDir="@{outputDir}" />
<listener type="legacy-plain" sendSysOut="true" outputDir="@{outputDir}"/> <listener type="legacy-plain" sendSysOut="true" outputDir="@{outputDir}"/>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true" outputDir="@{outputDir}"/> <listener type="legacy-xml" sendSysOut="true" sendSysErr="true" outputDir="@{outputDir}"/>
<listener classname="Junit5Progress"/>
<elements/> <elements/>
</testclasses> </testclasses>
</junitlauncher> </junitlauncher>
<loadfile property="contents" srcFile="build/status-as-tests-run.txt" /> <loadfile property="contents" srcFile="@{outputDir}/status-as-tests-run.txt" />
<echo message="${contents}" /> <echo message="${contents}" />
</sequential> </sequential>
</macrodef> </macrodef>

View File

@ -36,7 +36,7 @@ import org.junit.platform.launcher.TestPlan;
**/ **/
public class Junit5Progress implements TestExecutionListener { public class Junit5Progress implements TestExecutionListener {
private StringWriter inMemoryWriter = new StringWriter(); private final StringWriter inMemoryWriter = new StringWriter();
private int numSkippedInCurrentClass; private int numSkippedInCurrentClass;
private int numAbortedInCurrentClass; private int numAbortedInCurrentClass;
@ -97,10 +97,14 @@ public class Junit5Progress implements TestExecutionListener {
} }
/* /*
* Append to file on disk since listener can't write to System.out (becuase legacy listeners enabled) * Append to file on disk since listener can't write to System.out (because legacy listeners enabled)
*
* Implementing/using the TestResultFormatter - mentioned in the junitlauncher ant manual -
* doesn't work currently, because the output is truncated/overwritten with every test
*/ */
private void flushToDisk() { private void flushToDisk() {
try (FileWriter writer = new FileWriter("build/status-as-tests-run.txt", true)) { String outFile = System.getProperty("junit5.progress.file", "build/status-as-tests-run.txt");
try (FileWriter writer = new FileWriter(outFile, true)) {
writer.write(inMemoryWriter.toString()); writer.write(inMemoryWriter.toString());
} catch (IOException e) { } catch (IOException e) {
throw new UncheckedIOException(e); throw new UncheckedIOException(e);