Hello folks,
I just experienced a weird issue.
We configured pitest in a big gradle project.
Everything used to work fine, then all of a sudden we started experiencing some weird error when the pitest task runs in CD pipelines.
The gradle plugin (version 1.9.11) is configured as follows, and I'm configuring the useClasspathFile argument
```
apply plugin: 'info.solidsoft.pitest'
pitest {
targetClasses = propertyAsSetWithDefault('targetClasses', DEFAULT_PACKAGES)
targetTests = propertyAsSetWithDefault('targetTests', DEFAULT_PACKAGES)
excludedClasses = propertyAsSetWithDefault('excludedClasses', ['*.wiring.*'])
excludedTestClasses = propertyAsSetWithDefault('excludedTestClasses', [])
avoidCallsTo = propertyAsSetWithDefault('avoidCallsTo', [])
reportDir = file("$rootDir/reports/pitest/$moduleReportPath/")
mutators = propertyAsSetWithDefault('mutators', DEFAULT_MUTATORS)
jvmArgs = ['-Xmx1024m']
jvmArgs.addAll(
'--add-opens=java.base/java.lang=ALL-UNNAMED',
'--add-opens=java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens=java.base/java.lang.ref=ALL-UNNAMED',
)
mainProcessJvmArgs = ['-Djdk.attach.allowAttachSelf=true']
useClasspathFile = true
withHistory = true
}
```
when the pitest task is executed on CD machines it returns the error:
Exception in thread "main"
org.pitest.util.PitError: Cannot run program "/opt/jdk17/bin/java": error=7, Argument list too long
Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : Java HotSpot(TM) 64-Bit Server VM
Vendor : Oracle Corporation
Version : 17.0.1+12-LTS-39
Uptime : 1318
Input ->
1 : -Djdk.attach.allowAttachSelf=true
2 : -Dfile.encoding=UTF-8
3 : -Duser.country=US
4 : -Duser.language=en
5 : -Duser.variant
BootClassPathSupported : false
at org.pitest.util.Unchecked.translateCheckedException(Unchecked.java:20)
at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:106)
at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:52)
at org.pitest.mutationtest.tooling.MutationCoverage.runAnalysis(MutationCoverage.java:149)
at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:139)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:125)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:52)
at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:98)
at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
Caused by: java.io.IOException: Cannot run program "/opt/jdk17/bin/java": error=7, Argument list too long
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at org.pitest.process.WrappingProcess.start(WrappingProcess.java:48)
at org.pitest.coverage.execute.CoverageProcess.start(CoverageProcess.java:30)
at org.pitest.coverage.execute.DefaultCoverageGenerator.gatherCoverageData(DefaultCoverageGenerator.java:137)
at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:90)
... 7 more
Caused by: java.io.IOException: error=7, Argument list too long
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 12 more
The error is not occurring on machines where development occurs (they are both linux machines).
I noticed in the logs of the machines where the task fails that it's logging:
useClasspathJar=false
so I tried to modify the gradle configuration to include the
useClasspathJar=true
next to the already present
useClasspathFile=true
and it seems that this allowed the task to run correctly.
Both environments are using the same major java version:
Environment that works without useClasspathJar:
java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+10-LTS-37)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+10-LTS-37, mixed mode, sharing)
Environment that works only if useClasspathJar is specified:
java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
Has anybody else experienced something like this?
Thanks and regards,
Ugo