Add user defined tags to Tests.Group

This commit is contained in:
frosforever 2020-05-01 18:58:39 -04:00
parent 5a529bf10c
commit b2942f6321
3 changed files with 10 additions and 5 deletions

View File

@ -28,7 +28,7 @@ private[sbt] object ForkTests {
classpath: Seq[File],
fork: ForkOptions,
log: Logger,
tag: Tag
tags: (Tag, Int)*
): Task[TestOutput] = {
val opts = processOptions(config, tests, log)
@ -41,7 +41,7 @@ private[sbt] object ForkTests {
constant(TestOutput(TestResult.Passed, Map.empty[String, SuiteResult], Iterable.empty))
else
mainTestTask(runners, opts, classpath, fork, log, config.parallel).tagw(config.tags: _*)
main.tag(tag).dependsOn(all(opts.setup): _*) flatMap { results =>
main.tagw(tags: _*).dependsOn(all(opts.setup): _*) flatMap { results =>
all(opts.cleanup).join.map(_ => results)
}
}

View File

@ -133,7 +133,12 @@ object Tests {
final case class SubProcess(config: ForkOptions) extends TestRunPolicy
/** A named group of tests configured to run in the same JVM or be forked. */
final case class Group(name: String, tests: Seq[TestDefinition], runPolicy: TestRunPolicy)
final case class Group(
name: String,
tests: Seq[TestDefinition],
runPolicy: TestRunPolicy,
tags: Seq[(Tag, Int)] = Seq.empty
)
private[sbt] final class ProcessedOptions(
val tests: Vector[TestDefinition],

View File

@ -1208,7 +1208,7 @@ object Defaults extends BuildCommon {
): Initialize[Task[Tests.Output]] = {
val runners = createTestRunners(frameworks, loader, config)
val groupTasks = groups map {
case Tests.Group(_, tests, runPolicy) =>
case Tests.Group(_, tests, runPolicy, tags) =>
runPolicy match {
case Tests.SubProcess(opts) =>
s.log.debug(s"javaOptions: ${opts.runJVMOptions}")
@ -1221,7 +1221,7 @@ object Defaults extends BuildCommon {
cp.files,
opts,
s.log,
Tags.ForkedTestGroup
(Tags.ForkedTestGroup, 1) +: tags: _*
)
case Tests.InProcess =>
if (javaOptions.nonEmpty) {