Workaround for pitest not being able to deal with wildcard paths on Windows

This commit is contained in:
Erik C. Thauvin 2025-03-25 14:37:33 -07:00
parent ebef9ea3d5
commit e9f1fe25d9
Signed by: erik
GPG key ID: 776702A6A2DA330E

View file

@ -432,9 +432,10 @@ public class PitestOperation extends AbstractProcessOperation<PitestOperation> {
if (project_ != null) {
args.add(javaTool());
args.add("-cp");
args.add(String.format("%s%s%s%s%s%s%s", new File(project_.libTestDirectory(), "*"), File.pathSeparator,
new File(project_.libCompileDirectory(), "*"), File.pathSeparator, project_.buildMainDirectory(),
File.pathSeparator, project_.buildTestDirectory()));
args.add(String.format("%s%s%s%s%s%s", joinClasspathJar(project_.testClasspathJars()),
joinClasspathJar(project_.compileClasspathJars()),
joinClasspathJar(project_.providedClasspathJars()),
project_.buildMainDirectory(), File.pathSeparator, project_.buildTestDirectory()));
args.add("org.pitest.mutationtest.commandline.MutationCoverageReport");
if (!options_.containsKey(SOURCE_DIRS)) {
@ -686,6 +687,14 @@ public class PitestOperation extends AbstractProcessOperation<PitestOperation> {
return s != null && !s.isBlank();
}
private String joinClasspathJar(List<File> jars) {
if (!jars.isEmpty()) {
return String.join(File.pathSeparator, jars.stream().map(File::getAbsolutePath).toList()) + File.pathSeparator;
} else {
return "";
}
}
/**
* Argument string to use when PIT launches child processes. This is most commonly used to increase the amount of
* memory available to the process, but may be used to pass any valid JVM argument.