|
1 | 1 | package com.github.daniel.shuy.sbt.scripted.scalatest |
2 | 2 |
|
3 | | -import org.scalatest.Suite |
| 3 | +import org.scalatest.{ScriptedScalaTestSuite, Suite} |
4 | 4 | import sbt._ |
5 | 5 | import sbt.Keys.streams |
6 | 6 |
|
@@ -51,23 +51,28 @@ object SbtScriptedScalaTest extends AutoPlugin { |
51 | 51 | scriptedScalaTest := { |
52 | 52 | // do nothing if not configured |
53 | 53 | scriptedScalaTestSpec.value match { |
54 | | - case Some(suite) => |
55 | | - val stacks = scriptedScalaTestStacks.value |
56 | | - val status = suite.executeScripted( |
57 | | - durations = scriptedScalaTestDurations.value, |
58 | | - shortstacks = stacks.shortstacks, |
59 | | - fullstacks = stacks.fullstacks, |
60 | | - stats = scriptedScalaTestStats.value |
61 | | - ) |
62 | | - status.waitUntilCompleted() |
63 | | - if (!status.succeeds()) { |
64 | | - sys.error("Scripted ScalaTest suite failed!") |
65 | | - } |
| 54 | + case Some(suite) => executeScriptedTestsTask(suite) |
66 | 55 | case None => |
67 | 56 | logger.value.warn( |
68 | 57 | s"${scriptedScalaTestSpec.key.label} not configured, no tests will be run..." |
69 | 58 | ) |
70 | 59 | } |
71 | 60 | } |
72 | 61 | ) |
| 62 | + |
| 63 | + private[this] def executeScriptedTestsTask( |
| 64 | + suite: ScriptedScalaTestSuite |
| 65 | + ): Unit = Def.task { |
| 66 | + val stacks = scriptedScalaTestStacks.value |
| 67 | + val status = suite.executeScripted( |
| 68 | + durations = scriptedScalaTestDurations.value, |
| 69 | + shortstacks = stacks.shortstacks, |
| 70 | + fullstacks = stacks.fullstacks, |
| 71 | + stats = scriptedScalaTestStats.value |
| 72 | + ) |
| 73 | + status.waitUntilCompleted() |
| 74 | + if (!status.succeeds()) { |
| 75 | + sys.error("Scripted ScalaTest suite failed!") |
| 76 | + } |
| 77 | + } |
73 | 78 | } |
0 commit comments