mirror of https://github.com/sbt/sbt.git
Fail test action when explicit test names are invalid
This commit is contained in:
parent
fdd0e14e71
commit
88787d8569
|
|
@ -167,7 +167,7 @@ trait ScalaProject extends SimpleScalaProject with FileTasks with MultiTaskProje
|
|||
testTask(frameworks, classpath, analysis, options)
|
||||
def testTask(frameworks: Seq[TestFramework], classpath: PathFinder, analysis: CompileAnalysis, options: => Seq[TestOption]): Task =
|
||||
{
|
||||
def work =
|
||||
def rawWork =
|
||||
{
|
||||
val (begin, work, end) = testTasks(frameworks, classpath, analysis, options)
|
||||
val beginTasks = begin.map(toTask).toSeq // test setup tasks
|
||||
|
|
@ -177,6 +177,10 @@ trait ScalaProject extends SimpleScalaProject with FileTasks with MultiTaskProje
|
|||
val rootTask = Empty named("test-complete") dependsOn(workTasks.toSeq : _*) // the task that depends on all test subtasks
|
||||
SubWork[Project#Task](rootTask, endTask)
|
||||
}
|
||||
def errorTask(e: TestSetupException) = task { Some(e.getMessage) } named("test-setup")
|
||||
def work =
|
||||
try { rawWork }
|
||||
catch { case e: TestSetupException => SubWork[Project#Task](errorTask(e)) }
|
||||
new CompoundTask(work)
|
||||
}
|
||||
private def toTask(testTask: NamedTestTask) = task(testTask.run()) named(testTask.name)
|
||||
|
|
@ -381,6 +385,7 @@ object ScalaProject
|
|||
def optionsAsString(options: Seq[ScalaProject#CompileOption]) = options.map(_.asString).filter(!_.isEmpty)
|
||||
def javaOptionsAsString(options: Seq[ScalaProject#JavaCompileOption]) = options.map(_.asString)
|
||||
}
|
||||
final class TestSetupException(msg: String) extends RuntimeException(msg)
|
||||
trait MultiTaskProject extends Project
|
||||
{
|
||||
def multiTask(allTests: => List[String])(run: (Seq[String], String => Boolean) => Task): MethodTask = {
|
||||
|
|
@ -398,12 +403,12 @@ trait MultiTaskProject extends Project
|
|||
{
|
||||
val toCheck = Set() ++ includeTests -- allTests
|
||||
|
||||
if(!toCheck.isEmpty && log.atLevel(Level.Warn))
|
||||
if(!toCheck.isEmpty)
|
||||
{
|
||||
log.warn("Test(s) not found:")
|
||||
toCheck.foreach(test => log.warn("\t" + test))
|
||||
log.error("Test(s) not found:")
|
||||
toCheck.foreach(test => log.error("\t" + test))
|
||||
throw new TestSetupException("Invalid test name(s): " + toCheck.mkString(", "))
|
||||
}
|
||||
toCheck
|
||||
}
|
||||
lazy val includeTestsSet =
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue