Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags.ForkedTestGroup doesn't work #2677

Closed
pauldraper opened this issue Jul 19, 2016 · 1 comment
Closed

Tags.ForkedTestGroup doesn't work #2677

pauldraper opened this issue Jul 19, 2016 · 1 comment
Assignees

Comments

@pauldraper
Copy link
Contributor

pauldraper commented Jul 19, 2016

http://www.scala-sbt.org/0.13/docs/Testing.html

Control the number of forked JVMs allowed to run at the same time by setting the limit on Tags.ForkedTestGroup tag, which is 1 by default.


project/build.properties

sbt.version=0.13.12

build.sbt

concurrentRestrictions in Global := Seq(
  Tags.limit(Tags.ForkedTestGroup, 2)
)

libraryDependencies += "org.specs2" %% "specs2-core" % "3.7" % Test

scalaVersion := "2.11.7"

inConfig(Test)(Seq(
  fork := true,
  testGrouping := definedTests.value.map { test =>
    new Tests.Group(test.name, Seq(test), Tests.SubProcess(
      ForkOptions(
        javaHome.value,
        outputStrategy.value,
        Nil,
        Some(baseDirectory.value),
        javaOptions.value,
        connectInput.value,
        envVars.value
      )
    ))
  }
))

src/test/scala/example/Test.scala

package example

import org.specs2.mutable.Specification

trait Test extends Specification {
  Thread.sleep(10 * 1000)
}

class Test0 extends Test

class Test1 extends Test

class Test2 extends Test

class Test3 extends Test

Then

$ sbt test
...
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 12 s, completed Jul 18, 2016 7:30:10 PM

It should take at least 20 seconds to finish the tests, but ForkedTestGroup doesn't actually limit the number of forked test groups that run at a time.

@pauldraper pauldraper changed the title ForkedTestGroup doesn't work Tags.ForkedTestGroup doesn't work Jul 19, 2016
@pauldraper
Copy link
Contributor Author

The issue is that the wrong task is being tagged. Workaround:

inConfig(Test)(Seq(
    tags in test += Tags.ForkedTestGroup -> 1,
    tags in testOnly += Tags.ForkedTestGroup -> 1,
    tags in testQuick += Tags.ForkedTestGroup -> 1,
))

pauldraper added a commit to pauldraper/sbt that referenced this issue Jul 22, 2016
pauldraper added a commit to pauldraper/sbt that referenced this issue Jul 22, 2016
eed3si9n added a commit that referenced this issue Jul 25, 2016
eed3si9n pushed a commit to eed3si9n/sbt that referenced this issue Jan 14, 2017
@eed3si9n eed3si9n self-assigned this Jan 14, 2017
eed3si9n added a commit that referenced this issue Jan 15, 2017
[fport] Fix #2677: Tags.ForkedTestGroup doesn't work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants