apache / apache/maven-surefire

[SUREFIRE-2233] Unable to create file for report (File name too long)

Open
#2,697 4 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Filipe Roque](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=froque)** opened **[SUREFIRE-2233](https://issues.apache.org/jira/browse/SUREFIRE-2233?redirect=false)** and commented

surefire tries to create report files where the filename includes the package.

On Linux with eCryptfs, it easily fails with _File name too long_ ([What is the maximum allowed filename (and folder) size with eCryptfs?](https://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs/32834)), without failing the maven build.

 
* Should this error fail the build ?
* What is the solution for this, besides shorter packages and file names, or non encrypted file systems ?
* Maybe create sub directories under target/surefire-reports matching the packages
* shorten the filename like logback (https://logback.qos.ch/manual/layouts.html#conversionWord)

 

**pom.xml**

```java

4.0.0

org.example
long-filenames
1.0-SNAPSHOT


21
21
UTF-8



org.junit.jupiter
junit-jupiter-api
5.10.1
test




org.apache.maven.plugins
maven-surefire-plugin
3.2.5



```

{**}src/test/java/package1/subpackage2/subpackage3/subpackage4/subpackage5/subpackage6/subpackage7/TestWithAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFileName.java{**}{*}`*`

 

```java
package package1.subpackage2.subpackage3.subpackage4.subpackage5.subpackage6.subpackage7;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestWithAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFileName {

@Test
public void test() {
Assertions.assertTrue(true);
}
}
```

 

 

 

 

```java
❯ /opt/maven/apache-maven-3.9.5/bin/mvn clean test 
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.example:long-filenames >---------------------
[INFO] Building long-filenames 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- clean:3.2.0:clean (default-clean) @ long-filenames ---
[INFO] Deleting /home/froque/workspace/testes/long-filenames/target
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ long-filenames ---
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ long-filenames ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ long-filenames ---
[INFO] skip non existing resourceDirectory /home/froque/workspace/testes/long-filenames/src/test/resources
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ long-filenames ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 1 source file with javac [debug target 21] to target/test-classes
[INFO] 
[INFO] --- surefire:3.2.5:test (default-test) @ long-filenames ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running package1.subpackage2.subpackage3.subpackage4.subpackage5.subpackage6.subpackage7.TestWithAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFileName
[WARNING] ForkStarter IOException: Unable to create file for report: /home/froque/workspace/testes/long-filenames/target/surefire-reports/package1.subpackage2.subpackage3.subpackage4.subpackage5.subpackage6.subpackage7.TestWithAVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFileName.txt (File name too long). See the dump file /home/froque/workspace/testes/long-filenames/target/surefire-reports/2024-01-15T22-47-50_794-jvmRun1.dumpstream
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.564 s
[INFO] Finished at: 2024-01-15T22:47:51Z
[INFO] ------------------------------------------------------------------------

```

 

 

---

**Affects:** 3.2.5

Contributor guide

Open the contributing guide

Research direction

Start with the pom.xml and reproduce the warning using the long package and test class shown, running mvn clean test. Inspect how Surefire writes files under target/surefire-reports; done should be a defined, tested outcome for an overlong report filename without silently reporting zero tests and a successful build.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.