Skip to content

Commit 0aad768

Browse files
committed
quote all classpath entries to handle spaces
1 parent 0938a9e commit 0aad768

File tree

8 files changed

+140
-8
lines changed

8 files changed

+140
-8
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
include:
17-
- title: "JDK 11"
18-
java: 11
19-
- title: "JDK 18"
20-
java: "18"
17+
# - title: "JDK 11"
18+
# java: 11
19+
# - title: "JDK 18"
20+
# java: "18"
2121
- title: "JDK 21"
2222
java: "21"
2323
runs-on: ubuntu-latest

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ trigger:
33

44
strategy:
55
matrix:
6-
mac:
7-
imageName: 'macos-latest'
6+
# mac:
7+
# imageName: 'macos-latest'
88
windows:
99
imageName: 'windows-latest'
1010

pitest-entry/src/main/java/org/pitest/process/Java9Process.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ private List<String> createLaunchArgs(JavaAgent agentJarLocator, List<String> ar
108108
List<String> cmd = new ArrayList<>();
109109

110110
cmd.add("-classpath");
111-
cmd.add(classPath);
112-
111+
cmd.add(classPath.replace(" ", "\" \""));
112+
113113
addPITJavaAgent(agentJarLocator, cmd);
114114

115115
cmd.addAll(args);
@@ -154,4 +154,5 @@ private static Predicate<String> isJavaAgentParam() {
154154
return a -> a.toLowerCase().startsWith("-javaagent");
155155
}
156156

157+
157158
}

pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ public void shouldProduceConsistantCoverageData() throws Exception {
100100
assertEquals(firstRun, secondRun);
101101
}
102102

103+
@Test
104+
public void shouldHandleSpacesInProjectPath() throws Exception {
105+
File testDir = prepare("/pit spaces in path");
106+
verifier.executeGoal("test");
107+
verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage");
108+
109+
String firstRun = readCoverage(testDir);
110+
verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage");
111+
112+
String secondRun = readCoverage(testDir);
113+
assertEquals(firstRun, secondRun);
114+
}
115+
103116
@Test
104117
public void shouldExcludeSpecifiedJUnitCategories() throws Exception {
105118
File testDir = prepare("/pit-junit-categories");
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.example</groupId>
5+
<artifactId>deterministic-coverage</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>deterministic-coverage</name>
9+
<dependencies>
10+
<dependency>
11+
<groupId>junit</groupId>
12+
<artifactId>junit</artifactId>
13+
<version>${junit.version}</version>
14+
</dependency>
15+
</dependencies>
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-compiler-plugin</artifactId>
21+
<version>2.4</version>
22+
<configuration>
23+
<source>1.8</source>
24+
<target>1.8</target>
25+
</configuration>
26+
</plugin>
27+
<plugin>
28+
<groupId>org.pitest</groupId>
29+
<artifactId>pitest-maven</artifactId>
30+
<version>${pit.version}</version>
31+
<configuration>
32+
<exportLineCoverage>true</exportLineCoverage>
33+
<features>+CLASSLIMIT(limit[1])</features>
34+
<timestampedReports>false</timestampedReports>
35+
<targetClasses><param>com.example*</param></targetClasses>
36+
<verbose>true</verbose>
37+
</configuration>
38+
</plugin>
39+
</plugins>
40+
</build>
41+
42+
43+
<properties>
44+
<junit.version>4.13.1</junit.version>
45+
</properties>
46+
47+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example;
2+
3+
public class CoveredByMultipleThreads {
4+
5+
public int lotsOfLinesOfCode(int i) {
6+
if ( i == 0 ) {
7+
return 1;
8+
}
9+
10+
if ( i == 2 ) {
11+
return 42;
12+
}
13+
14+
for ( int j = 0; j != 100; j++ ) {
15+
try {
16+
Thread.sleep(1);
17+
} catch (InterruptedException e) {
18+
e.printStackTrace();
19+
}
20+
}
21+
22+
return i;
23+
}
24+
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.example;
2+
3+
import java.util.Arrays;
4+
import java.util.Collection;
5+
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.junit.runners.Parameterized;
9+
import org.junit.runners.Parameterized.Parameters;
10+
11+
@RunWith(value = Parameterized.class)
12+
public class MultiThreadedTest {
13+
14+
private final int i;
15+
16+
@Parameters
17+
public static Collection<Object[]> data() {
18+
Object[][] data = new Object[][] { { 1 }, { 2 }, { 3 }, { 4 }, { 5 } ,{ 6 }, { 7 }, { 8 } };
19+
return Arrays.asList(data);
20+
}
21+
22+
public MultiThreadedTest(int i) {
23+
this.i = i;
24+
}
25+
26+
@Test
27+
public void test() throws InterruptedException {
28+
Thread t = new Thread(aTest());
29+
t.start();
30+
t.join();
31+
}
32+
33+
34+
35+
private Runnable aTest() {
36+
return new Runnable() {
37+
public void run() {
38+
CoveredByMultipleThreads testee = new CoveredByMultipleThreads();
39+
testee.lotsOfLinesOfCode(i);
40+
}
41+
42+
};
43+
};
44+
45+
}

pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.net.URL;
1212
import java.util.Arrays;
1313
import java.util.Collections;
14+
import java.util.Optional;
1415

1516
import org.junit.Before;
1617
import org.junit.Test;

0 commit comments

Comments
 (0)