Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
update for pitest 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed May 21, 2014
1 parent e0acf69 commit 9d485d1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

.cache
*.class
*.log
.classpath
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ name := "sbt-pit"

organization := "org.pitest.sbt"

version := "0.32"
version := "1.0.0-SNAPSHOT"

crossScalaVersions := Seq("2.9.2", "2.10.1")
crossScalaVersions := Seq("2.9.2", "2.10.1", "2.11.0")

resolvers += "Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository"

libraryDependencies += "org.pitest" % "pitest" % "0.32"
libraryDependencies += "org.pitest" % "pitest" % "1.0.0"

libraryDependencies += "org.pitest" % "pitest-html-report" % "0.32"
libraryDependencies += "org.pitest" % "pitest-html-report" % "1.0.0"

publishTo <<= (version) { version: String =>
val scalasbt = "http://repo.scala-sbt.org/scalasbt/"
Expand Down
34 changes: 20 additions & 14 deletions src/main/scala/org/pitest/sbt/PitPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import java.io.IOException
import java.net.URLDecoder
import org.pitest.util.Glob
import org.pitest.mutationtest.config.ConfigurationFactory
import org.pitest.testng.TestGroupConfig
import java.util.Collection
import java.util.ArrayList
import org.pitest.mutationtest.config.ConfigOption
Expand All @@ -21,6 +20,8 @@ import org.pitest.classpath.ClassPathByteArraySource
import org.pitest.mutationtest.config.ReportOptions
import org.pitest.mutationtest.config.PluginServices
import org.pitest.plugin.ClientClasspathPlugin
import org.pitest.testapi.TestGroupConfig
import org.pitest.util.IsolationUtils


object PitPlugin extends Plugin {
Expand Down Expand Up @@ -65,9 +66,10 @@ object PitPlugin extends Plugin {
Thread.currentThread().setContextClassLoader(PitPlugin.getClass.getClassLoader())

try {
val ps = new PluginServices(IsolationUtils.getContextClassLoader())
val pit = new EntryPoint
val data = makeReportOptions(options, conf, paths, filters, excludes)
val result = pit.execute( paths.baseDir, data)
val data = makeReportOptions(options, conf, paths, filters, excludes, ps)
val result = pit.execute( paths.baseDir, data, ps)

if ( result.getError().hasSome() ) {
result.getError().value().printStackTrace()
Expand All @@ -81,11 +83,16 @@ object PitPlugin extends Plugin {

}

def makeReportOptions(options : Options, config : Configuration, paths: PathSettings, filters: FilterSettings, excludes: Excludes): ReportOptions = {
def makeReportOptions(options: Options, config: Configuration
, paths: PathSettings
, filters: FilterSettings
, excludes: Excludes
, ps: PluginServices): ReportOptions = {

val data = new ReportOptions
data.setReportDir(paths.targetPath.getAbsolutePath())
data.setClassPathElements(plainCollection(makeClasspath(paths)))
data.setCodePaths(plainCollection (paths.mutatablePath map (p => p.getPath)) )
data.setClassPathElements(plainCollection(makeClasspath(paths, ps)))
data.setCodePaths(plainCollection(paths.mutatablePath map (p => p.getPath)))
data.setTargetClasses(plainCollection(filters.targetClasses map toGlob))
data.setTargetTests(plainCollection(filters.targetTests map toGlob))
data.setDependencyAnalysisMaxDistance(filters.dependencyDistance)
Expand All @@ -102,18 +109,17 @@ object PitPlugin extends Plugin {
data.setExcludedClasses(plainCollection(excludes.excludedClasses map toGlob))
data.setExcludedMethods(plainCollection(excludes.excludedMethods map toGlob))
data.setLoggingClasses(plainCollection(excludes.excludedMethods))

data.setMutationEngine(config.engine)
data.setMutators(plainCollection(config.mutators))
data.addOutputFormats(plainCollection(config.outputFormats))
val conf = new TestGroupConfig(plainCollection(config.excludedGroups),plainCollection(config.includedGroups))

val conf = new TestGroupConfig(plainCollection(config.excludedGroups), plainCollection(config.includedGroups))
data.setGroupConfig(conf)

val configFactory = new ConfigurationFactory(conf,
new ClassPathByteArraySource(data.getClassPath()));
new ClassPathByteArraySource(data.getClassPath()));
data.setConfiguration(configFactory.createConfiguration())


data
}
Expand All @@ -128,9 +134,9 @@ object PitPlugin extends Plugin {
new ArrayList(s)
}

private def makeClasspath(paths: org.pitest.sbt.PathSettings) : Seq[String] = {
private def makeClasspath(paths: org.pitest.sbt.PathSettings, ps : PluginServices ) : Seq[String] = {
val cp = paths.classPath.files map (f => f.getPath().trim())
val services = PluginServices.findClientClasspathPlugins().asScala
val services = ps.findClientClasspathPlugins().asScala
val pluginPaths = services map ( c => pathTo(c.getClass()) )
cp ++ pluginPaths.toSet
}
Expand Down

0 comments on commit 9d485d1

Please sign in to comment.