Skip to content

Commit

Permalink
Merge pull request #1292 from Friendseeker/better-handle-illegal-scri…
Browse files Browse the repository at this point in the history
…pted-test

Improving error message for illegal zinc scripted test when running `zincScripted/Test/run`
  • Loading branch information
eed3si9n authored Nov 30, 2023
2 parents a9b4f04 + 3fbe6bf commit 604f73a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ScriptedMain {
run(baseDir, buffer = !disableBuffering, compileToJar, tests)
}

private def detectScriptedTests(scriptedBase: File): Map[String, Set[String]] = {
def detectScriptedTests(scriptedBase: File): Map[String, Set[String]] = {
val scriptedFiles: NameFilter = ("test": NameFilter) | "pending"
val pairs = (scriptedBase * AllPassFilter * AllPassFilter * scriptedFiles).get.map { f =>
val p = f.getParentFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import sbt.io.IO
import sbt.util.{ Level, Logger }

import scala.collection.parallel.ParSeq
import sbt.inc.ScriptedMain._

object ScriptedRunnerImpl {
type TestRunner = () => Seq[Option[String]]
Expand Down Expand Up @@ -59,6 +60,11 @@ object ScriptedRunnerImpl {
reportErrors(tests.flatMap(test => test.apply()).flatten.toList)
}

def listTests(baseDir: Path, log: Logger): Seq[ScriptedTest] =
new ListTests(baseDir.toFile, _ => true, log).listTests
def listTests(baseDir: Path, log: Logger): Seq[ScriptedTest] = {
val foundScriptedTests = detectScriptedTests(baseDir.toFile)
def isScriptedTest(test: ScriptedTest) = {
foundScriptedTests(test.group).contains(test.name)
}
new ListTests(baseDir.toFile, isScriptedTest, log).listTests
}
}

0 comments on commit 604f73a

Please sign in to comment.