From: Dominik Stadler Date: Sun, 20 Mar 2022 08:20:05 +0000 (+0000) Subject: Avoid flaky tests with parallel execution X-Git-Tag: REL_5_2_3~414 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=42985f64df0c7a150dc011b5b2e41a8aa5efeafd;p=poi.git Avoid flaky tests with parallel execution One test stores and deletes files named "-saved.xls", so we need to prevent other tests from reading those git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899077 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java index 563d7dce14..d487fffe06 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java @@ -136,6 +136,7 @@ public class TestAllFiles { final List result = new ArrayList<>(100); for (String file : scanner.getIncludedFiles()) { // avoid running on files leftover from previous failed runs + // or being created by tests run in parallel if(file.endsWith("-saved.xls") || file.endsWith("TestHPSFWritingFunctionality.doc")) { continue; } diff --git a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java index 6a36ae6cda..065fe6a70a 100644 --- a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java +++ b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java @@ -91,6 +91,14 @@ public abstract class BaseTestIteratingXLS { @ParameterizedTest @MethodSource("files") void testMain(File file, Class t) throws Exception { + // avoid running files leftover from previous failed runs + // or created by tests running in parallel + // otherwise this would cause sporadic failures with + // parallel test execution + if(file.getName().endsWith("-saved.xls")) { + return; + } + Executable ex = () -> runOneFile(file); if (t == null) { assertDoesNotThrow(ex);