Fix #3746: Scripted should fail when no tests match the pattern

This commit is contained in:
gayanMatch 2026-01-09 13:57:58 -06:00
parent 061145e67b
commit 65af6c59d6
3 changed files with 8 additions and 1 deletions

View File

@ -33,6 +33,9 @@ object ScriptedRunnerImpl {
case ScriptedTest(group, name) =>
runner.scriptedTest(group, name, logger, context)
}
if (tests.nonEmpty && allTests.isEmpty) {
sys.error(s"No tests found matching: ${tests.mkString(", ")}")
}
runAll(allTests)
}
def runAll(tests: Seq[() => Option[String]]): Unit = {

View File

@ -104,7 +104,7 @@ object Scripted {
launcherJar: File,
logger: Logger
): 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("")
// Force Log4J to not use a thread context classloader otherwise it throws a CCE

View File

@ -589,6 +589,10 @@ class ScriptedRunner {
val groupCount = if (parallelExecution) instances else Int.MaxValue
val scriptedRunners =
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) {
import scala.collection.parallel.CollectionConverters.*
val parallelRunners = scriptedRunners.toArray.par