Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative scripted filenames #4220

Merged
merged 1 commit into from Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion main/src/main/scala/sbt/ScriptedPlugin.scala
Expand Up @@ -120,7 +120,8 @@ object ScriptedPlugin extends AutoPlugin {
private[sbt] def scriptedParser(scriptedBase: File): Parser[Seq[String]] = {
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 {
(f: File) =>
val p = f.getParentFile
Expand Down
1 change: 1 addition & 0 deletions sbt/src/sbt-test/project/test-script-file/build.sbt
@@ -0,0 +1 @@
lazy val root = (project in file("."))
1 change: 1 addition & 0 deletions sbt/src/sbt-test/project/test-script-file/test.script
@@ -0,0 +1 @@
> test
15 changes: 10 additions & 5 deletions scripted/sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala
Expand Up @@ -8,7 +8,7 @@
package sbt
package scriptedtest

import java.io.File
import java.io.{ File, FileNotFoundException }
import java.net.SocketException
import java.util.Properties
import java.util.concurrent.ForkJoinPool
Expand All @@ -17,7 +17,6 @@ import scala.collection.GenSeq
import scala.collection.mutable
import scala.collection.parallel.ForkJoinTaskSupport
import scala.util.control.NonFatal

import sbt.internal.scripted._
import sbt.internal.io.Resources
import sbt.internal.util.{ BufferedLogger, ConsoleLogger, FullLogger }
Expand Down Expand Up @@ -386,9 +385,15 @@ final class ScriptedTests(
if (bufferLog) log.record()

val (file, pending) = {
val normal = new File(testDirectory, ScriptFilename)
val pending = new File(testDirectory, PendingScriptFilename)
if (pending.isFile) (pending, true) else (normal, false)
val normal = (new File(testDirectory, ScriptFilename), false)
val normalScript = (new File(testDirectory, s"$ScriptFilename.script"), 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 ""
Expand Down