From c9208a47195939834c270b10febc03b54731eed1 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Thu, 27 Feb 2014 10:40:42 +0000 Subject: [PATCH 1/3] Completed a full example of forked tests with grouping The previous example of how to fork group of tests in different JVMs was incomplete and not fully working. a) The "testGrouping in Test" is needed, otherwise the grouping is not known to which phase to apply b) Added a more complete Project definition to explain what the curly brackets section refers to and where the settings need to be included The new complete example works out of the box :-) --- src/sphinx/Detailed-Topics/Testing.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sphinx/Detailed-Topics/Testing.rst b/src/sphinx/Detailed-Topics/Testing.rst index 120c1b740..d33021508 100644 --- a/src/sphinx/Detailed-Topics/Testing.rst +++ b/src/sphinx/Detailed-Topics/Testing.rst @@ -195,14 +195,22 @@ available with :key:`testGrouping` key. For example: :: + import sbt._ + import Keys._ import Tests._ + import Defaults._ - { + object ForkTestsBuild extends Build { def groupByFirst(tests: Seq[TestDefinition]) = tests groupBy (_.name(0)) map { case (letter, tests) => new Group(letter.toString, tests, SubProcess(Seq("-Dfirst.letter"+letter))) } toSeq; - testGrouping := groupByFirst( (definedTests in Test).value ) + + lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq( + scalaVersion := "2.10.3", + testGrouping in Test := groupByFirst( (definedTests in Test).value ), + libraryDependencies += "org.scalatest" %% "scalatest" % "2.0" % "test" + )) } The tests in a single group are run sequentially. Control the number From 63583d2544eddc793eb23256850011900e03c42f Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Thu, 27 Feb 2014 10:51:06 +0000 Subject: [PATCH 2/3] Removed redundant semicolon --- src/sphinx/Detailed-Topics/Testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sphinx/Detailed-Topics/Testing.rst b/src/sphinx/Detailed-Topics/Testing.rst index d33021508..67704e7a2 100644 --- a/src/sphinx/Detailed-Topics/Testing.rst +++ b/src/sphinx/Detailed-Topics/Testing.rst @@ -204,7 +204,7 @@ available with :key:`testGrouping` key. For example: def groupByFirst(tests: Seq[TestDefinition]) = tests groupBy (_.name(0)) map { case (letter, tests) => new Group(letter.toString, tests, SubProcess(Seq("-Dfirst.letter"+letter))) - } toSeq; + } toSeq lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq( scalaVersion := "2.10.3", From bedfb12163da3172f0abee76508648b635a64161 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Fri, 28 Feb 2014 15:18:08 +0000 Subject: [PATCH 3/3] Making example specific to build.sbt (see discussion on https://github.com/sbt/sbt/pull/1139) --- src/sphinx/Detailed-Topics/Testing.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/sphinx/Detailed-Topics/Testing.rst b/src/sphinx/Detailed-Topics/Testing.rst index 67704e7a2..c3ff52fa3 100644 --- a/src/sphinx/Detailed-Topics/Testing.rst +++ b/src/sphinx/Detailed-Topics/Testing.rst @@ -191,26 +191,19 @@ The setting: specifies that all tests will be executed in a single external JVM. See :doc:`Forking` for configuring standard options for forking. More control over how tests are assigned to JVMs and what options to pass to those is -available with :key:`testGrouping` key. For example: +available with :key:`testGrouping` key. For example in build.sbt: :: - import sbt._ - import Keys._ import Tests._ - import Defaults._ - object ForkTestsBuild extends Build { + { def groupByFirst(tests: Seq[TestDefinition]) = tests groupBy (_.name(0)) map { case (letter, tests) => new Group(letter.toString, tests, SubProcess(Seq("-Dfirst.letter"+letter))) } toSeq - lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq( - scalaVersion := "2.10.3", - testGrouping in Test := groupByFirst( (definedTests in Test).value ), - libraryDependencies += "org.scalatest" %% "scalatest" % "2.0" % "test" - )) + testGrouping in Test <<= groupByFirst( (definedTests in Test).value ) } The tests in a single group are run sequentially. Control the number