mirror of https://github.com/sbt/sbt.git
Fix #3746: Scripted should fail when no tests match the pattern
This commit is contained in:
parent
061145e67b
commit
65af6c59d6
|
|
@ -33,6 +33,9 @@ object ScriptedRunnerImpl {
|
||||||
case ScriptedTest(group, name) =>
|
case ScriptedTest(group, name) =>
|
||||||
runner.scriptedTest(group, name, logger, context)
|
runner.scriptedTest(group, name, logger, context)
|
||||||
}
|
}
|
||||||
|
if (tests.nonEmpty && allTests.isEmpty) {
|
||||||
|
sys.error(s"No tests found matching: ${tests.mkString(", ")}")
|
||||||
|
}
|
||||||
runAll(allTests)
|
runAll(allTests)
|
||||||
}
|
}
|
||||||
def runAll(tests: Seq[() => Option[String]]): Unit = {
|
def runAll(tests: Seq[() => Option[String]]): Unit = {
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ object Scripted {
|
||||||
launcherJar: File,
|
launcherJar: File,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Unit = {
|
): Unit = {
|
||||||
logger.info(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
|
logger.info(s"Tests selected: ${args.mkString("\n * ", "\n * ", "\n")}")
|
||||||
logger.info("")
|
logger.info("")
|
||||||
|
|
||||||
// Force Log4J to not use a thread context classloader otherwise it throws a CCE
|
// Force Log4J to not use a thread context classloader otherwise it throws a CCE
|
||||||
|
|
|
||||||
|
|
@ -589,6 +589,10 @@ class ScriptedRunner {
|
||||||
val groupCount = if (parallelExecution) instances else Int.MaxValue
|
val groupCount = if (parallelExecution) instances else Int.MaxValue
|
||||||
val scriptedRunners =
|
val scriptedRunners =
|
||||||
runner.batchScriptedRunner(scriptedTests, addTestFile, groupCount, prop, logger)
|
runner.batchScriptedRunner(scriptedTests, addTestFile, groupCount, prop, logger)
|
||||||
|
// Fail if user provided test patterns but none matched any existing test directories
|
||||||
|
if (tests.nonEmpty && scriptedRunners.isEmpty) {
|
||||||
|
sys.error(s"No tests found matching: ${tests.mkString(", ")}")
|
||||||
|
}
|
||||||
if (parallelExecution && instances > 1) {
|
if (parallelExecution && instances > 1) {
|
||||||
import scala.collection.parallel.CollectionConverters.*
|
import scala.collection.parallel.CollectionConverters.*
|
||||||
val parallelRunners = scriptedRunners.toArray.par
|
val parallelRunners = scriptedRunners.toArray.par
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue