diff options
Diffstat (limited to 'plugins/scalatest/ScalaTest.scala')
-rw-r--r-- | plugins/scalatest/ScalaTest.scala | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/plugins/scalatest/ScalaTest.scala b/plugins/scalatest/ScalaTest.scala index e2f44e3..87ab16d 100644 --- a/plugins/scalatest/ScalaTest.scala +++ b/plugins/scalatest/ScalaTest.scala @@ -1,42 +1,11 @@ package cbt -import org.scalatest._ - - +import java.io.File trait ScalaTest extends BaseBuild{ + override def dependencies = super.dependencies :+ libraries.scalatestRunner override def run: ExitCode = { - import ScalaTestLib._ - val suiteNames = exportedClasspath.files.map( d => discoverSuites(d, classLoader) ).flatten - runSuites( suiteNames.map( loadSuite( _, classLoader ) ) ) + classLoader.loadClass( "cbt.scalatest.Runner" ).method( + "run", classOf[Array[File]], classOf[ClassLoader] + ).invoke( null, exportedClasspath.files.toArray, classLoader ) ExitCode.Success } - override def dependencies = super.dependencies ++ Resolver( mavenCentral ).bind( ScalaDependency("org.scalatest","scalatest","2.2.4") ) } - -object ScalaTestLib{ - import java.io.File - def runSuites(suites: Seq[Suite]) = { - def color: Boolean = true - def durations: Boolean = true - def shortstacks: Boolean = true - def fullstacks: Boolean = true - def stats: Boolean = true - def testName: String = null - def configMap: ConfigMap = ConfigMap.empty - suites.foreach{ - _.execute(testName, configMap, color, durations, shortstacks, fullstacks, stats) - } - } - - def discoverSuites(discoveryPath: File, classLoader: ClassLoader): Seq[String] = { - classLoader - .loadClass("org.scalatest.tools.SuiteDiscoveryHelper") - .getMethod("discoverSuiteNames", classOf[List[_]], classOf[ClassLoader], classOf[Option[_]]) - .invoke(null, List(discoveryPath.string ++ "/"), classLoader, None) - .asInstanceOf[Set[String]] - .toVector - } - def loadSuite(name: String, classLoader: ClassLoader) = { - classLoader.loadClass(name).getConstructor().newInstance().asInstanceOf[Suite] - } -} - |