Alexander Myltsev
Alexander Myltsev

Reputation: 499

Pipeline log message and test-task

Having test task defined as follows

lazy val UnitTest = config("unit").extend(Test)

Project("my-project", file("."))

testOptions in UnitTest := Seq(
    Tests.Argument("-h", "target/test-html"),
    Tests.Argument("-u", "target/test-xml"),
    Tests.Argument("-C", "SlowestTestReporter"),
    Tests.Argument("-oD"),
    Tests.Filter(testName => !testName.endsWith("Prop") && !testName.contains("Integration"))
)

Somebody please explain me why test-task override prints test output in first, and only after message "=== Unit Tests ==="

test in Test := {
  streams.value.log("=== Unit Tests ===")
  (test in UnitTest).value
}

And if I redefine test as follows then everything works as expected

test in Test := (test in UnitTest).dependsOn(unitTestsWelcome).value

Upvotes: 1

Views: 77

Answers (2)

Eugene Yokota
Eugene Yokota

Reputation: 95624

See Execution semantics of tasks.

Unlike plain Scala method calls, invoking value method on tasks will not be evaluated strictly. Instead, they simply act as placeholders to denote that sampleIntTask depends on startServer and stopServer tasks.

Upvotes: 1

jsuereth
jsuereth

Reputation: 5624

.value defines a dependency. All dependencies are computed prior to your task, not inline. See sbt-sequential if you'd like sequential semantics on task dependencies.

Upvotes: 2

Related Questions