Skip to content

Commit 241b952

Browse files
authored
Merge pull request #14 from daniel-shuy/feature/shorten-code-unit
Fix Better Code Hub "Write Short Units of Code" guideline
2 parents 054f9ee + 4528e06 commit 241b952

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/main/scala/com/github/daniel/shuy/sbt/scripted/scalatest/SbtScriptedScalaTest.scala

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.daniel.shuy.sbt.scripted.scalatest
22

3-
import org.scalatest.Suite
3+
import org.scalatest.{ScriptedScalaTestSuite, Suite}
44
import sbt._
55
import sbt.Keys.streams
66

@@ -51,23 +51,28 @@ object SbtScriptedScalaTest extends AutoPlugin {
5151
scriptedScalaTest := {
5252
// do nothing if not configured
5353
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)
6655
case None =>
6756
logger.value.warn(
6857
s"${scriptedScalaTestSpec.key.label} not configured, no tests will be run..."
6958
)
7059
}
7160
}
7261
)
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+
}
7378
}

0 commit comments

Comments
 (0)