-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds support for FuncSuite with the following changes: - New agent to define for ignoring tests because when the runner loads the test ignorer, the class has been already loaded, which means that can not be changed. - Checking if the test extends from FuncSuite - ScalaTest creates a constructor per Test class, and inside the constructor, calls the tests. This patch ignores this kind of tests by replacing the method call "test" by "ignore".
- Loading branch information
Showing
8 changed files
with
332 additions
and
35 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
56 changes: 56 additions & 0 deletions
56
junit4git/src/main/java/org/walkmod/junit4git/core/bytecode/TestIgnorerTransformer.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,56 @@ | ||
package org.walkmod.junit4git.core.bytecode; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.walkmod.junit4git.core.ignorers.TestIgnorer; | ||
import org.walkmod.junit4git.core.reports.TestMethodReport; | ||
import org.walkmod.junit4git.javassist.JavassistUtils; | ||
|
||
import java.lang.instrument.ClassFileTransformer; | ||
import java.lang.instrument.IllegalClassFormatException; | ||
import java.security.ProtectionDomain; | ||
import java.util.*; | ||
|
||
|
||
public class TestIgnorerTransformer implements ClassFileTransformer { | ||
|
||
|
||
private static Log log = LogFactory.getLog(TestIgnorerTransformer.class); | ||
|
||
private final TestIgnorer testIgnorer; | ||
|
||
private final Map<String, List<TestMethodReport>> testsToMap; | ||
|
||
public TestIgnorerTransformer(TestIgnorer testIgnorer) throws Exception { | ||
this.testIgnorer = testIgnorer; | ||
testsToMap = testIgnorer.testsGroupedByClass(); | ||
log.info("Last Test Impact Analysis: " + testsToMap.size() + " tests"); | ||
} | ||
|
||
@Override | ||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, | ||
ProtectionDomain protectionDomain, byte[] classfileBuffer) | ||
throws IllegalClassFormatException { | ||
String name = normalizeName(className); | ||
try { | ||
if (testsToMap.containsKey(name)) { | ||
log.info("Ignoring " + name); | ||
return testIgnorer.ignoreTest(name, testsToMap.get(name)); | ||
} | ||
return classfileBuffer; | ||
|
||
} catch (Exception e) { | ||
log.error("Error ignoring the tests of " + name, e); | ||
throw new IllegalClassFormatException("Error ignoring tests on " + name); | ||
} | ||
} | ||
|
||
private String normalizeName(String className) { | ||
String aux = className.replaceAll("/", "\\."); | ||
if (aux.endsWith(".class")) { | ||
aux = aux.substring(0, aux.length() - ".class".length()); | ||
} | ||
return aux; | ||
} | ||
|
||
} |
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
22 changes: 22 additions & 0 deletions
22
junit4git/src/main/java/org/walkmod/junit4git/core/ignorers/TestIgnorerAgent.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,22 @@ | ||
package org.walkmod.junit4git.core.ignorers; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.walkmod.junit4git.core.bytecode.TestIgnorerTransformer; | ||
import org.walkmod.junit4git.core.reports.GitTestReportStorage; | ||
|
||
import java.lang.instrument.Instrumentation; | ||
|
||
public class TestIgnorerAgent { | ||
|
||
private static Log log = LogFactory.getLog(TestIgnorerAgent.class); | ||
|
||
public static void premain(String args, Instrumentation instrumentation) { | ||
log.info("JUnit4Git agent started"); | ||
try { | ||
instrumentation.addTransformer(new TestIgnorerTransformer(new TestIgnorer(new GitTestReportStorage()))); | ||
} catch (Exception e) { | ||
log.error(e); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.