-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1348 from hcoles/feature/monkey_patching
Extend transformation extension point
- Loading branch information
Showing
12 changed files
with
74 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
pitest/src/main/java/org/pitest/mutationtest/mocksupport/JavassistTransformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.pitest.mutationtest.mocksupport; | ||
|
||
import org.pitest.coverage.execute.JavassistCoverageInterceptor; | ||
import org.pitest.functional.prelude.Prelude; | ||
import org.pitest.mutationtest.environment.TransformationPlugin; | ||
import org.pitest.util.Glob; | ||
|
||
import java.lang.instrument.ClassFileTransformer; | ||
|
||
public class JavassistTransformation implements TransformationPlugin { | ||
|
||
@Override | ||
public ClassFileTransformer makeCoverageTransformer() { | ||
return new BendJavassistToMyWillTransformer(Prelude | ||
.or(new Glob("javassist/*")), | ||
JavassistInputStreamInterceptorAdapter.inputStreamAdapterSupplier(JavassistCoverageInterceptor.class)); | ||
} | ||
|
||
@Override | ||
public ClassFileTransformer makeMutationTransformer() { | ||
return new BendJavassistToMyWillTransformer(Prelude | ||
.or(new Glob("javassist/*")), | ||
JavassistInputStreamInterceptorAdapter.inputStreamAdapterSupplier(JavassistInterceptor.class)); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Support for mocking frameworks using javassist"; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
pitest/src/main/java/org/pitest/mutationtest/mocksupport/ResetJavassistEnvironment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.pitest.mutationtest.mocksupport; | ||
|
||
import org.pitest.mutationtest.environment.EnvironmentResetPlugin; | ||
import org.pitest.mutationtest.environment.ResetEnvironment; | ||
|
||
public class ResetJavassistEnvironment implements EnvironmentResetPlugin { | ||
@Override | ||
public ResetEnvironment make() { | ||
return JavassistInterceptor::setMutant; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Reset environment for javassist"; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...in/resources/META-INF/services/org.pitest.mutationtest.environment.EnvironmentResetPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.pitest.mutationtest.mocksupport.ResetJavassistEnvironment |
1 change: 1 addition & 0 deletions
1
...main/resources/META-INF/services/org.pitest.mutationtest.environment.TransformationPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.pitest.mutationtest.mocksupport.JavassistTransformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters