Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In a related <a href="https://github.com/sbt/sbt/issues/1001" rel="nofollow">github issue discussion</a>, Josh suggested an approach to the particular case I asked about (overriding it:test with a task that calls the original test task). </p> <p>The approach works by reimplementing the test task. I don't know if there's a more general way to get access to the original version of the task. (A more general way would be a better answer than this one!)</p> <p>Here's how to reimplement the it:test task:</p> <pre><code> /** run integration tests (just like it:test does, but explicitly so we can overwrite the it:test key */ lazy val itTestTask: Initialize[Task[Unit]] = Def.taskDyn { for { results &lt;- (executeTests in IntegrationTest) } yield { Tests.showResults(streams.value.log, results, "test missing?") } } </code></pre> <p>Here's the composite integration test task (evolved slighly from the original question, though that version should work too):</p> <pre><code> /** run integration tests against a test server. (the server is started before the tests and stopped after the tests) */ lazy val testWithServiceTask = Def.taskDyn { (start in testService).value match { case Success(_) =&gt; testAndStop case Failure(e) =&gt; val stack = e.getStackTrace().mkString("\n") streams.value.log.error(s"failed to start test server: $e \n ${stack}") emptyTask } } /** run integration tests and then stop the test server */ lazy val testAndStop = Def.taskDyn { SbtUtil.sequence(itTestTask, stop in testService) } val emptyTask = Def.task {} </code></pre> <p>And now plugging the composite task we've built into the it:test key doesn't create a cycle:</p> <pre><code> lazy val mohs = Project(id = "mohs", base = file(".")) .settings ( test in IntegrationTest &lt;&lt;= testWithServiceTask, ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload