diff --git a/src/main/scala/com/github/daniel/shuy/sbt/scripted/scalatest/SbtScriptedScalaTest.scala b/src/main/scala/com/github/daniel/shuy/sbt/scripted/scalatest/SbtScriptedScalaTest.scala index 93b9f16..8858b52 100644 --- a/src/main/scala/com/github/daniel/shuy/sbt/scripted/scalatest/SbtScriptedScalaTest.scala +++ b/src/main/scala/com/github/daniel/shuy/sbt/scripted/scalatest/SbtScriptedScalaTest.scala @@ -39,36 +39,37 @@ object SbtScriptedScalaTest extends AutoPlugin { } import autoImport._ - private[this] lazy val logger = Def.task[Logger] { - streams.value.log - } - override def projectSettings: Seq[Setting[_]] = Seq( scriptedScalaTestDurations := true, scriptedScalaTestStacks := NoStacks, scriptedScalaTestStats := true, scriptedScalaTestSpec := None, scriptedScalaTest := { + val duration = scriptedScalaTestDurations.value + val stacks = scriptedScalaTestStacks.value + val stats = scriptedScalaTestStats.value + val log = streams.value.log // do nothing if not configured scriptedScalaTestSpec.value match { - case Some(suite) => executeScriptedTestsTask(suite) + case Some(suite) => + executeScriptedTestsTask(suite, duration, stacks, stats) case None => - logger.value.warn( - s"${scriptedScalaTestSpec.key.label} not configured, no tests will be run..." - ) + log.warn(s"${scriptedScalaTestSpec.key.label} not configured, no tests will be run...") } } ) private[this] def executeScriptedTestsTask( - suite: ScriptedScalaTestSuite - ): Unit = Def.task { - val stacks = scriptedScalaTestStacks.value + suite: ScriptedScalaTestSuite, + showDuration: Boolean, + stacks: ScriptedTestStacks, + stats: Boolean, + ): Unit = { val status = suite.executeScripted( - durations = scriptedScalaTestDurations.value, + durations = showDuration, shortstacks = stacks.shortstacks, fullstacks = stacks.fullstacks, - stats = scriptedScalaTestStats.value + stats = stats ) status.waitUntilCompleted() if (!status.succeeds()) { diff --git a/src/sbt-test/sbt-1.0/testFailure/build.sbt b/src/sbt-test/sbt-1.0/testFailure/build.sbt index ebfa701..8242fae 100644 --- a/src/sbt-test/sbt-1.0/testFailure/build.sbt +++ b/src/sbt-test/sbt-1.0/testFailure/build.sbt @@ -1,3 +1,5 @@ +import scala.sys.process._ + import com.github.daniel.shuy.sbt.scripted.scalatest.ScriptedScalaTestSuiteMixin import org.scalatest.Assertions._ import org.scalatest.wordspec.AnyWordSpec @@ -23,6 +25,9 @@ lazy val testFailure = project "scripted" should { "fail on ScalaTest failure" in { + val pidFile = new File("target/pid") + (s"echo ${ProcessHandle.current.pid}" #> pidFile).!! + assertThrows[sbt.Incomplete]( Project.extract(sbtState) .runInputTask(scripted, "", sbtState)) diff --git a/src/sbt-test/sbt-1.0/testFailure/test b/src/sbt-test/sbt-1.0/testFailure/test index 57e380e..fb4759d 100644 --- a/src/sbt-test/sbt-1.0/testFailure/test +++ b/src/sbt-test/sbt-1.0/testFailure/test @@ -1 +1,3 @@ +$ delete target/pid > scriptedScalatest +$ exists target/pid