Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-2159

Better test temp dir managemenent

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Maven Surefire Plugin
    • None

    Description

      How to achieve to put UTs temporary directory under target/something?

      Currently, there is one way to do it:

              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                  <systemPropertyVariables>
                    <java.io.tmpdir>${project.build.directory}/surefire-tmp</java.io.tmpdir>
                  </systemPropertyVariables>
                </configuration>
              </plugin>
      

      This works as expected, BUT the temp directory DOES NOT EXISTS, so one have to sprinkle UTs (each, unless you lock down test run ordering) with code like this:

      Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir"))); // hack for Surefire
      

      As otherwise, all Java Files.createTempFile will throw like this:

      java.nio.file.NoSuchFileException: /home/runner/work/maven-resolver/maven-resolver/maven-resolver-impl/target/surefire-tmp/artifact5917045446313461619tmp
      	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
      	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
      	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
      	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
      	at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
      	at java.base/java.nio.file.Files.createFile(Files.java:648)
      	at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:137)
      	at java.base/java.nio.file.TempFileHelper.createTempFile(TempFileHelper.java:160)
      	at java.base/java.nio.file.Files.createTempFile(Files.java:913)
      	at org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessorTest.prepareSubject(TrustedChecksumsArtifactResolverPostProcessorTest.java:77)
      ...
      

      So, the idea: just like existing tempDir (that is somewhat misleading, as it says "Relative path to temporary-surefire-boot directory containing internal Surefire temporary files.") add some new property that would:

      • set java.tmp.dir on provider/forked JVM
      • create the directory (make sure it exists)

      As then, config could become simpler, and no "sprinkling" of mkdirs would be needed as surefire would handle it:

              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                  <providerTempDir>${project.build.directory}/surefire-tmp</providerTempDir>
                </configuration>
              </plugin>
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            cstamas Tamas Cservenak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: