Add scripted tests

This commit is contained in:
frosforever 2020-05-03 12:39:58 -04:00
parent 18d51eac58
commit 2e4e3bbe13
3 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,33 @@
val specs = "org.specs2" %% "specs2-core" % "4.3.4"
ThisBuild / scalaVersion := "2.12.11"
val TestATypeTag = Tags.Tag("TestA")
val TestBTypeTag = Tags.Tag("TestB")
Global / concurrentRestrictions := Seq(Tags.limit(TestATypeTag, 1), Tags.limit(TestBTypeTag, 1))
libraryDependencies += specs % Test
inConfig(Test)(Seq(
testGrouping := {
val home = javaHome.value
val strategy = outputStrategy.value
val baseDir = baseDirectory.value
val options = javaOptions.value
val connect = connectInput.value
val vars = envVars.value
definedTests.value.map { test => new Tests.Group(test.name, Seq(test), Tests.SubProcess(
ForkOptions(
javaHome = home,
outputStrategy = strategy,
bootJars = Vector(),
workingDirectory = Some(baseDir),
runJVMOptions = options.toVector,
connectInput = connect,
envVars = vars
)
), Seq((if (test.name.contains("TestA")) TestATypeTag else TestBTypeTag) -> 1))
}
},
TaskKey[Unit]("test-failure") := test.failure.value
))

View File

@ -0,0 +1,33 @@
package example
import java.io.File
import org.specs2.mutable.Specification
trait Test extends Specification {
def testType: String
"spec" should {
"be run one at time" in {
val lock = new File(s"lock${testType}")
println(lock)
lock.mkdir() should beTrue
Thread.sleep(2000)
lock.delete() should beTrue
}
}
}
class TestA0 extends Test {
override def testType: String = "A"
}
class TestA1 extends Test {
override def testType: String = "A"
}
class TestB0 extends Test {
override def testType: String = "B"
}
class TestB1 extends Test {
override def testType: String = "B"
}

View File

@ -0,0 +1,3 @@
> test
> set concurrentRestrictions in Global := Seq(Tags.limitAll(4))
> testFailure