From 3446af59a17bdef8730008a61eade7937b9cda56 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Thu, 30 Mar 2017 10:47:28 -0400 Subject: scalatest plugin for 2.12 (and move most code from plugin into library) --- plugins/scalatest/ScalaTest.scala | 41 +++++-------------------------------- plugins/scalatest/build/build.scala | 2 -- 2 files changed, 5 insertions(+), 38 deletions(-) (limited to 'plugins') 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] - } -} - diff --git a/plugins/scalatest/build/build.scala b/plugins/scalatest/build/build.scala index ce07b36..4e94cd7 100644 --- a/plugins/scalatest/build/build.scala +++ b/plugins/scalatest/build/build.scala @@ -4,7 +4,5 @@ class Build(val context: Context) extends BaseBuild{ override def dependencies = ( super.dependencies :+ context.cbtDependency - ) ++ Resolver( mavenCentral ).bind( - ScalaDependency("org.scalatest","scalatest","2.2.4") ) } -- cgit v1.2.3