mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
Abstract over runAll and runInParallel
This is the best we can do without using structural types.
This commit is contained in:
@@ -201,17 +201,15 @@ class ScriptedRunner {
|
|||||||
runAllInParallel(scriptedTestRunners.toParArray)
|
runAllInParallel(scriptedTestRunners.toParArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
def runAll(tests: Seq[ScriptedTests.TestRunner]): Unit = {
|
private def reportErrors(errors: Seq[String]): Unit =
|
||||||
val errors = for (test <- tests; err <- test()) yield err
|
if (errors.nonEmpty) sys.error(errors.mkString("Failed tests:\n\t", "\n\t", "\n")) else ()
|
||||||
if (errors.nonEmpty)
|
|
||||||
sys.error(errors.mkString("Failed tests:\n\t", "\n\t", "\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
def runAllInParallel(tests: ParSeq[ScriptedTests.TestRunner]): Unit = {
|
def runAll(tests: Seq[ScriptedTests.TestRunner]): Unit =
|
||||||
val executedTests = tests.flatMap(test => test.apply().toList).toList
|
reportErrors(tests.flatMap(test => test.apply().toSeq))
|
||||||
if (executedTests.nonEmpty)
|
|
||||||
sys.error(executedTests.mkString("Failed tests:\n\t", "\n\t", "\n"))
|
// We cannot reuse `runAll` because parallel collections != collections
|
||||||
}
|
def runAllInParallel(tests: ParSeq[ScriptedTests.TestRunner]): Unit =
|
||||||
|
reportErrors(tests.flatMap(test => test.apply().toSeq).toList)
|
||||||
|
|
||||||
def get(tests: Seq[String], baseDirectory: File, log: Logger): Seq[ScriptedTest] =
|
def get(tests: Seq[String], baseDirectory: File, log: Logger): Seq[ScriptedTest] =
|
||||||
if (tests.isEmpty) listTests(baseDirectory, log) else parseTests(tests)
|
if (tests.isEmpty) listTests(baseDirectory, log) else parseTests(tests)
|
||||||
|
|||||||
Reference in New Issue
Block a user