Skip to content

Commit

Permalink
195: a first attempt with pit bundles
Browse files Browse the repository at this point in the history
NOT WORKING

Task-Url: #195
  • Loading branch information
LorenzoBettini committed Jul 28, 2022
1 parent 18ff04b commit e69ae09
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 38 deletions.
6 changes: 6 additions & 0 deletions bundles/org.pitest.bundles/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions bundles/org.pitest.bundles/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.pitest.bundles</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
21 changes: 21 additions & 0 deletions bundles/org.pitest.bundles/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
org.eclipse.jdt.core.builder.invalidClasspath=abort
org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=ignore
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
13 changes: 13 additions & 0 deletions bundles/org.pitest.bundles/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pitest Bundles
Bundle-SymbolicName: org.pitest.bundles;singleton:=true
Bundle-Version: 2.2.0.qualifier
Bundle-Vendor: Henry Coles
Automatic-Module-Name: org.pitest.bundles
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: wrapped.org.pitest.pitest;visibility:=reexport,
wrapped.org.pitest.pitest-command-line;visibility:=reexport,
wrapped.org.pitest.pitest-entry;visibility:=reexport,
wrapped.org.pitest.pitest-html-report;visibility:=reexport,
org.junit;bundle-version="4.12.0"
2 changes: 2 additions & 0 deletions bundles/org.pitest.bundles/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin.includes = META-INF/,\
.
4 changes: 2 additions & 2 deletions bundles/org.pitest.pitclipse.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Bundle-Activator: org.pitest.pitclipse.core.PitCoreActivator
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.1,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.11.2,4.0.0)",
org.pitest.pitclipse.runner;bundle-version="[2.0.0,3.0.0)",
org.pitest;bundle-version="1.6.8",
org.eclipse.core.resources;bundle-version="[3.10.1,4.0.0)",
org.eclipse.ui;bundle-version="[3.107.0,4.0.0)"
org.eclipse.ui;bundle-version="[3.107.0,4.0.0)",
org.pitest.bundles;visibility:=reexport
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: Pitest.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Pitclipse's Pitest Listeners
Bundle-SymbolicName: org.pitest.pitclipse.listeners
Bundle-Version: 2.2.0.qualifier
Fragment-Host: org.pitest;bundle-version="1.6.8"
Fragment-Host: org.pitest.bundles;bundle-version="1.6.8"
Automatic-Module-Name: org.pitest.pitclipse.listeners
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.pitest.pitclipse.runner;bundle-version="2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.pitest.pitclipse.runner/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bundle-Version: 2.2.0.qualifier
Bundle-Vendor: Pitest.org
Automatic-Module-Name: org.pitest.pitclipse.runner
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.pitest;bundle-version="1.6.8"
Require-Bundle: org.pitest.bundles;visibility:=reexport
Export-Package: org.pitest.pitclipse.runner,
org.pitest.pitclipse.runner.client,
org.pitest.pitclipse.runner.config,
Expand Down
11 changes: 3 additions & 8 deletions features/org.pitest.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,10 @@
</requires>

<plugin
id="org.pitest"
id="org.pitest.bundles"
download-size="0"
install-size="0"
version="0.0.0"/>

<plugin
id="org.pitest.pitest-junit5-plugin"
download-size="0"
install-size="0"
version="0.0.0"/>
version="0.0.0"
unpack="false"/>

</feature>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="org.pitest.pitclipse.target" sequenceNumber="9">
<target name="org.pitest.pitclipse.target" sequenceNumber="11">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.e4.core.tools.feature.source.feature.group" version="0.0.0"/>
Expand Down Expand Up @@ -62,16 +62,34 @@
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<artifactId>cucumber-java</artifactId>
<version>4.3.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<artifactId>cucumber-junit</artifactId>
<version>4.3.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-command-line</artifactId>
<version>1.6.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-html-report</artifactId>
<version>1.6.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.14</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
</locations>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.pitest.pitclipse.runner.tests"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.internal.framework.EquinoxBundle;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.pitest.mutationtest.MutationResultListenerFactory;
import org.pitest.pitclipse.example.empty.EmptyClass;
import org.pitest.pitclipse.runner.results.ObjectFactory;
Expand Down Expand Up @@ -157,24 +162,41 @@ private static PitOptions options(String classUnderTest, List<String> classesToM

private static List<String> classPathWithPitestAndJUnit() throws IOException {
final String jarDir = "lib";
return asList(
// TODO [Refactor] Pitest's classpath should be managed by the org.pitest bundle
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath(),
getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath(),
getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath() + File.separator + BUILD_OUTPUT_DIR,
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath()
+ File.separator + jarDir + File.separator + "pitest.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath()
+ File.separator + jarDir + File.separator + "pitest-entry.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath()
+ File.separator + jarDir + File.separator + "pitest-command-line.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath()
+ File.separator + jarDir + File.separator + "pitest-html-report.jar",
getBundleFile(Platform.getBundle("com.google.guava")).getCanonicalPath(),
// Add .class files to mutate
new File(BUILD_OUTPUT_DIR).getAbsolutePath(),
// Add JUnit dependency
new File("lib/junit.jar").getAbsolutePath()
);
EquinoxBundle pitestBundle = (EquinoxBundle) Platform.getBundle("org.pitest.bundles");
Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
System.out.println("symbolic name: " + pitestBundle.getSymbolicName());
List<EquinoxBundle> pitestWrappedBundles = Stream.of(bundles)
.filter(b -> b instanceof EquinoxBundle)
.map(b -> (EquinoxBundle) b)
.filter(b -> b.getSymbolicName().startsWith("wrapped.org.pitest"))
.collect(Collectors.toList());
List<String> locations = pitestWrappedBundles.stream()
.map(b -> b.getLocation())
.collect(Collectors.toList());
// hack, exclude JUnit 5?
locations.remove(locations.size() - 1);


List<String> classPath = new ArrayList<>();

// classPath.add(getBundleFile(pitestBundle).getCanonicalPath());

classPath.add(getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath());
classPath.add(getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath() + File.separator + BUILD_OUTPUT_DIR);

for (Bundle bundle : pitestWrappedBundles) {
classPath.add(getBundleFile(bundle).getCanonicalPath());
}

// Guava is needed
classPath.add(getBundleFile(Platform.getBundle("com.google.guava")).getCanonicalPath());

// Add .class files to mutate
classPath.add(new File(BUILD_OUTPUT_DIR).getAbsolutePath());

// Add JUnit dependency
classPath.add(new File("lib/junit.jar").getAbsolutePath());

return classPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class SummaryResultListenerFactoryTest {

private final SummaryResultListenerFactory factory = new SummaryResultListenerFactory();
Expand Down
4 changes: 2 additions & 2 deletions tests/org.pitest.pitclipse.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Require-Bundle: org.eclipse.swtbot.eclipse.finder,
org.pitest.pitclipse.runner;bundle-version="2.0.0",
org.apache.log4j;bundle-version="1.2.15",
org.eclipse.swtbot.junit4_x,
org.pitest;bundle-version="1.6.8",
org.objenesis;bundle-version="1.0.0",
org.eclipse.ui,
org.eclipse.core.runtime,
Expand All @@ -29,4 +28,5 @@ Require-Bundle: org.eclipse.swtbot.eclipse.finder,
wrapped.io.cucumber.cucumber-java;bundle-version="4.3.0",
wrapped.io.cucumber.cucumber-junit;bundle-version="4.3.0",
wrapped.io.cucumber.cucumber-core;bundle-version="4.3.0",
wrapped.io.cucumber.datatable;bundle-version="1.1.12"
wrapped.io.cucumber.datatable;bundle-version="1.1.12",
org.pitest.bundles

0 comments on commit e69ae09

Please sign in to comment.