diff --git a/main-actions/src/main/scala/sbt/ForkTests.scala b/main-actions/src/main/scala/sbt/ForkTests.scala index 58a3b0f20..3a0fb85f2 100755 --- a/main-actions/src/main/scala/sbt/ForkTests.scala +++ b/main-actions/src/main/scala/sbt/ForkTests.scala @@ -16,7 +16,7 @@ import sbt.protocol.testing._ private[sbt] object ForkTests { def apply(runners: Map[TestFramework, Runner], - tests: List[TestDefinition], + tests: Vector[TestDefinition], config: Execution, classpath: Seq[File], fork: ForkOptions, diff --git a/main-actions/src/main/scala/sbt/Tests.scala b/main-actions/src/main/scala/sbt/Tests.scala index bdd8f91b5..4b4f8f07e 100644 --- a/main-actions/src/main/scala/sbt/Tests.scala +++ b/main-actions/src/main/scala/sbt/Tests.scala @@ -128,13 +128,13 @@ object Tests { final case class Group(name: String, tests: Seq[TestDefinition], runPolicy: TestRunPolicy) private[sbt] final class ProcessedOptions( - val tests: Seq[TestDefinition], - val setup: Seq[ClassLoader => Unit], - val cleanup: Seq[ClassLoader => Unit], - val testListeners: Seq[TestReportListener] + val tests: Vector[TestDefinition], + val setup: Vector[ClassLoader => Unit], + val cleanup: Vector[ClassLoader => Unit], + val testListeners: Vector[TestReportListener] ) private[sbt] def processOptions(config: Execution, - discovered: Seq[TestDefinition], + discovered: Vector[TestDefinition], log: Logger): ProcessedOptions = { import collection.mutable.{ HashSet, ListBuffer } val testFilters = new ListBuffer[String => Boolean] @@ -172,7 +172,10 @@ object Tests { if (orderedFilters.isEmpty) filtered0 else orderedFilters.flatMap(f => filtered0.filter(d => f(d.name))).toList.distinct val uniqueTests = distinctBy(tests)(_.name) - new ProcessedOptions(uniqueTests, setup.toList, cleanup.toList, testListeners.toList) + new ProcessedOptions(uniqueTests.toVector, + setup.toVector, + cleanup.toVector, + testListeners.toVector) } private[this] def distinctBy[T, K](in: Seq[T])(f: T => K): Seq[T] = { @@ -183,7 +186,7 @@ object Tests { def apply(frameworks: Map[TestFramework, Framework], testLoader: ClassLoader, runners: Map[TestFramework, Runner], - discovered: Seq[TestDefinition], + discovered: Vector[TestDefinition], config: Execution, log: ManagedLogger): Task[Output] = { val o = processOptions(config, discovered, log) @@ -201,11 +204,11 @@ object Tests { def testTask(loader: ClassLoader, frameworks: Map[TestFramework, Framework], runners: Map[TestFramework, Runner], - tests: Seq[TestDefinition], + tests: Vector[TestDefinition], userSetup: Iterable[ClassLoader => Unit], userCleanup: Iterable[ClassLoader => Unit], log: ManagedLogger, - testListeners: Seq[TestReportListener], + testListeners: Vector[TestReportListener], config: Execution): Task[Output] = { def fj(actions: Iterable[() => Unit]): Task[Unit] = nop.dependsOn(actions.toSeq.fork(_()): _*) def partApp(actions: Iterable[ClassLoader => Unit]) = actions.toSeq map { a => () => diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 711f08118..558f7d15f 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -845,7 +845,7 @@ object Defaults extends BuildCommon { val forkedConfig = config.copy(parallel = config.parallel && forkedParallelExecution) s.log.debug(s"Forking tests - parallelism = ${forkedConfig.parallel}") ForkTests(runners, - tests.toList, + tests.toVector, forkedConfig, cp.files, opts, @@ -855,7 +855,7 @@ object Defaults extends BuildCommon { if (javaOptions.nonEmpty) { s.log.warn("javaOptions will be ignored, fork is set to false") } - Tests(frameworks, loader, runners, tests, config, s.log) + Tests(frameworks, loader, runners, tests.toVector, config, s.log) } } val output = Tests.foldTasks(groupTasks, config.parallel) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 6ab28e277..7d918eaaf 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -12,7 +12,7 @@ object Dependencies { // sbt modules private val ioVersion = "1.0.0-M11" - private val utilVersion = "1.0.0-M23" + private val utilVersion = "1.0.0-M24" private val lmVersion = "1.0.0-X11" private val zincVersion = "1.0.0-X14" diff --git a/reset.sh b/reset.sh index ec3465425..a09f0bc7f 100755 --- a/reset.sh +++ b/reset.sh @@ -1,3 +1,3 @@ #!/bin/bash -rm -rf ~/.sbt/boot/scala-2.11.8/org.scala-sbt/sbt/1.0.0-SNAPSHOT/ +rm -rf ~/.sbt/boot/scala-2.12.2/org.scala-sbt/sbt/1.0.0-SNAPSHOT/ diff --git a/testing/src/main/scala/sbt/TestFramework.scala b/testing/src/main/scala/sbt/TestFramework.scala index 8ebceb3ee..1a6a9ca0a 100644 --- a/testing/src/main/scala/sbt/TestFramework.scala +++ b/testing/src/main/scala/sbt/TestFramework.scala @@ -73,7 +73,7 @@ final class TestDefinition(val name: String, override def hashCode: Int = (name.hashCode, TestFramework.hashCode(fingerprint)).hashCode } -final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log: ManagedLogger) { +final class TestRunner(delegate: Runner, listeners: Vector[TestReportListener], log: ManagedLogger) { final def tasks(testDefs: Set[TestDefinition]): Array[TestTask] = delegate.tasks( @@ -93,10 +93,12 @@ final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log // here we get the results! here is where we'd pass in the event listener val results = new scala.collection.mutable.ListBuffer[Event] val handler = new EventHandler { def handle(e: Event): Unit = { results += e } } - val loggers = listeners.flatMap(_.contentLogger(testDefinition)) + val loggers: Vector[ContentLogger] = listeners.flatMap(_.contentLogger(testDefinition)) val nestedTasks = try testTask.execute(handler, loggers.map(_.log).toArray) - finally loggers.foreach(_.flush()) + finally { + loggers.foreach(_.flush()) + } val event = TestEvent(results) safeListenersCall(_.testEvent(event)) (SuiteResult(results), nestedTasks.toSeq) @@ -157,13 +159,13 @@ object TestFramework { frameworks: Map[TestFramework, Framework], runners: Map[TestFramework, Runner], testLoader: ClassLoader, - tests: Seq[TestDefinition], + tests: Vector[TestDefinition], log: ManagedLogger, - listeners: Seq[TestReportListener] - ): (() => Unit, Seq[(String, TestFunction)], TestResult => () => Unit) = { + listeners: Vector[TestReportListener] + ): (() => Unit, Vector[(String, TestFunction)], TestResult => () => Unit) = { val mappedTests = testMap(frameworks.values.toSeq, tests) if (mappedTests.isEmpty) - (() => (), Nil, _ => () => ()) + (() => (), Vector(), _ => () => ()) else createTestTasks(testLoader, runners.map { case (tf, r) => (frameworks(tf), new TestRunner(r, listeners, log)) @@ -171,7 +173,7 @@ object TestFramework { } private[this] def order(mapped: Map[String, TestFunction], - inputs: Seq[TestDefinition]): Seq[(String, TestFunction)] = + inputs: Vector[TestDefinition]): Vector[(String, TestFunction)] = for (d <- inputs; act <- mapped.get(d.name)) yield (d.name, act) private[this] def testMap(frameworks: Seq[Framework], @@ -193,9 +195,10 @@ object TestFramework { private def createTestTasks(loader: ClassLoader, runners: Map[Framework, TestRunner], tests: Map[Framework, Set[TestDefinition]], - ordered: Seq[TestDefinition], + ordered: Vector[TestDefinition], log: ManagedLogger, - listeners: Seq[TestReportListener]) = { + listeners: Vector[TestReportListener]) + : (() => Unit, Vector[(String, TestFunction)], TestResult => (() => Unit)) = { val testsListeners = listeners collect { case tl: TestsListener => tl } def foreachListenerSafe(f: TestsListener => Unit): () => Unit = diff --git a/testing/src/main/scala/sbt/internal/testing/TestLogger.scala b/testing/src/main/scala/sbt/internal/testing/TestLogger.scala index 36c32cde9..9eaf0a114 100644 --- a/testing/src/main/scala/sbt/internal/testing/TestLogger.scala +++ b/testing/src/main/scala/sbt/internal/testing/TestLogger.scala @@ -3,7 +3,7 @@ package internal.testing import testing.{ Logger => TLogger } import sbt.internal.util.{ ManagedLogger, BufferedAppender } -import sbt.util.{ Level, LogExchange } +import sbt.util.{ Level, LogExchange, ShowLines } import sbt.protocol.testing._ import java.util.concurrent.atomic.AtomicInteger import scala.collection.JavaConverters._ @@ -11,6 +11,11 @@ import scala.collection.JavaConverters._ object TestLogger { import sbt.protocol.testing.codec.JsonProtocol._ + implicit val testStringEventShowLines: ShowLines[TestStringEvent] = + ShowLines[TestStringEvent]({ + case a: TestStringEvent => List(a.value) + }) + private def generateName: String = "test-" + generateId.incrementAndGet private val generateId: AtomicInteger = new AtomicInteger @@ -38,11 +43,16 @@ object TestLogger { if (per.buffered) { buffs foreach { _.record() } } - new ContentLogger(wrap(newLog), () => { - buffs foreach { _.stopQuietly() } - per.flush() - }) + new ContentLogger( + wrap(newLog), + () => { + buffs foreach { _.stopQuietly() } + per.flush() + LogExchange.unbindLoggerAppenders(newLog.name) + } + ) } + global.registerStringCodec[TestStringEvent] val config = new TestLogging(wrap(global), global, makePerTest) new TestLogger(config) }