]> source.dussan.org Git - poi.git/commitdiff
Avoid flaky tests with parallel execution
authorDominik Stadler <centic@apache.org>
Sun, 20 Mar 2022 08:20:05 +0000 (08:20 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 20 Mar 2022 08:20:05 +0000 (08:20 +0000)
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

poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java

index 563d7dce1452aacebfd6289255a1b9a9a482017d..d487fffe06f0ca195479392cf7677bba4c22f6f9 100644 (file)
@@ -136,6 +136,7 @@ public class TestAllFiles {
         final List<Arguments> 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;
                        }
index 6a36ae6cdae382f984957b2bf418ed5f19721a1e..065fe6a70a5c6d33176a86249098ee3982dd6622 100644 (file)
@@ -91,6 +91,14 @@ public abstract class BaseTestIteratingXLS {
     @ParameterizedTest
     @MethodSource("files")
     void testMain(File file, Class<? extends Throwable> 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);