Merge pull request #4220 from regadas/issue/630

Add alternative scripted filenames
This commit is contained in:
eugene yokota 2018-06-19 22:03:18 -04:00 committed by GitHub
commit a34f76bab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View File

@ -120,7 +120,8 @@ object ScriptedPlugin extends AutoPlugin {
private[sbt] def scriptedParser(scriptedBase: File): Parser[Seq[String]] = { private[sbt] def scriptedParser(scriptedBase: File): Parser[Seq[String]] = {
import DefaultParsers._ import DefaultParsers._
val scriptedFiles: NameFilter = ("test": NameFilter) | "pending" val scriptedFiles
: NameFilter = ("test": NameFilter) | "test.script" | "pending" | "pending.script"
val pairs = (scriptedBase * AllPassFilter * AllPassFilter * scriptedFiles).get map { val pairs = (scriptedBase * AllPassFilter * AllPassFilter * scriptedFiles).get map {
(f: File) => (f: File) =>
val p = f.getParentFile val p = f.getParentFile

View File

@ -0,0 +1 @@
lazy val root = (project in file("."))

View File

@ -0,0 +1 @@
> test

View File

@ -8,7 +8,7 @@
package sbt package sbt
package scriptedtest package scriptedtest
import java.io.File import java.io.{ File, FileNotFoundException }
import java.net.SocketException import java.net.SocketException
import java.util.Properties import java.util.Properties
import java.util.concurrent.ForkJoinPool import java.util.concurrent.ForkJoinPool
@ -17,7 +17,6 @@ import scala.collection.GenSeq
import scala.collection.mutable import scala.collection.mutable
import scala.collection.parallel.ForkJoinTaskSupport import scala.collection.parallel.ForkJoinTaskSupport
import scala.util.control.NonFatal import scala.util.control.NonFatal
import sbt.internal.scripted._ import sbt.internal.scripted._
import sbt.internal.io.Resources import sbt.internal.io.Resources
import sbt.internal.util.{ BufferedLogger, ConsoleLogger, FullLogger } import sbt.internal.util.{ BufferedLogger, ConsoleLogger, FullLogger }
@ -386,9 +385,15 @@ final class ScriptedTests(
if (bufferLog) log.record() if (bufferLog) log.record()
val (file, pending) = { val (file, pending) = {
val normal = new File(testDirectory, ScriptFilename) val normal = (new File(testDirectory, ScriptFilename), false)
val pending = new File(testDirectory, PendingScriptFilename) val normalScript = (new File(testDirectory, s"$ScriptFilename.script"), false)
if (pending.isFile) (pending, true) else (normal, false) val pending = (new File(testDirectory, PendingScriptFilename), true)
val pendingScript = (new File(testDirectory, s"$PendingScriptFilename.script"), true)
List(pending, pendingScript, normal, normalScript).find(_._1.isFile) match {
case Some(script) => script
case None => throw new FileNotFoundException("no test scripts found")
}
} }
val pendingMark = if (pending) PendingLabel else "" val pendingMark = if (pending) PendingLabel else ""