Merge pull request #13 from sbt/wip/packagenames2

package name change and test migration
This commit is contained in:
eugene yokota 2015-09-07 02:51:08 -04:00
commit 349254362d
86 changed files with 306 additions and 254 deletions

3
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,3 @@
```
$ sbt release
```

View File

@ -33,14 +33,10 @@ def commonSettings: Seq[Setting[_]] = Seq(
publishArtifact in Test := true publishArtifact in Test := true
) )
def testedBaseSettings: Seq[Setting[_]] =
commonSettings ++ testDependencies
lazy val utilRoot: Project = (project in file(".")). lazy val utilRoot: Project = (project in file(".")).
// configs(Sxr.sxrConf).
aggregate( aggregate(
utilInterface, utilControl, utilCollection, utilApplyMacro, utilComplete, utilInterface, utilControl, utilCollection, utilApplyMacro, utilComplete,
utilLogging, utilRelation, utilLogic, utilCache, utilTracking utilLogging, utilRelation, utilLogic, utilCache, utilTracking, utilTesting
). ).
settings( settings(
inThisBuild(Seq( inThisBuild(Seq(
@ -65,7 +61,10 @@ lazy val utilRoot: Project = (project in file(".")).
name := "Util Root", name := "Util Root",
publish := {}, publish := {},
publishLocal := {}, publishLocal := {},
publishArtifact := false publishArtifact in Compile := false,
publishArtifact in Test := false,
publishArtifact := false,
customCommands
) )
// defines Java structures used across Scala versions, such as the API structures and relationships extracted by // defines Java structures used across Scala versions, such as the API structures and relationships extracted by
@ -86,8 +85,9 @@ lazy val utilControl = (project in internalPath / "util-control").
) )
lazy val utilCollection = (project in internalPath / "util-collection"). lazy val utilCollection = (project in internalPath / "util-collection").
dependsOn(utilTesting % Test).
settings( settings(
testedBaseSettings, commonSettings,
Util.keywordsSettings, Util.keywordsSettings,
name := "Util Collection" name := "Util Collection"
) )
@ -95,26 +95,25 @@ lazy val utilCollection = (project in internalPath / "util-collection").
lazy val utilApplyMacro = (project in internalPath / "util-appmacro"). lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
dependsOn(utilCollection). dependsOn(utilCollection).
settings( settings(
testedBaseSettings, commonSettings,
name := "Util Apply Macro", name := "Util Apply Macro",
libraryDependencies += scalaCompiler.value libraryDependencies += scalaCompiler.value
) )
// Command line-related utilities. // Command line-related utilities.
lazy val utilComplete = (project in internalPath / "util-complete"). lazy val utilComplete = (project in internalPath / "util-complete").
dependsOn(utilCollection, utilControl). dependsOn(utilCollection, utilControl, utilTesting % Test).
settings( settings(
testedBaseSettings, commonSettings,
name := "Util Completion", name := "Util Completion",
libraryDependencies ++= Seq(jline, sbtIO), libraryDependencies ++= Seq(jline, sbtIO)
crossScalaVersions := Seq(scala210, scala211)
) )
// logging // logging
lazy val utilLogging = (project in internalPath / "util-logging"). lazy val utilLogging = (project in internalPath / "util-logging").
dependsOn(utilInterface). dependsOn(utilInterface, utilTesting % Test).
settings( settings(
testedBaseSettings, commonSettings,
publishArtifact in (Test, packageBin) := true, publishArtifact in (Test, packageBin) := true,
name := "Util Logging", name := "Util Logging",
libraryDependencies += jline libraryDependencies += jline
@ -122,16 +121,17 @@ lazy val utilLogging = (project in internalPath / "util-logging").
// Relation // Relation
lazy val utilRelation = (project in internalPath / "util-relation"). lazy val utilRelation = (project in internalPath / "util-relation").
dependsOn(utilTesting % Test).
settings( settings(
testedBaseSettings, commonSettings,
name := "Util Relation" name := "Util Relation"
) )
// A logic with restricted negation as failure for a unique, stable model // A logic with restricted negation as failure for a unique, stable model
lazy val utilLogic = (project in internalPath / "util-logic"). lazy val utilLogic = (project in internalPath / "util-logic").
dependsOn(utilCollection, utilRelation). dependsOn(utilCollection, utilRelation, utilTesting % Test).
settings( settings(
testedBaseSettings, commonSettings,
name := "Util Logic" name := "Util Logic"
) )
@ -152,3 +152,21 @@ lazy val utilTracking = (project in internalPath / "util-tracking").
name := "Util Tracking", name := "Util Tracking",
libraryDependencies += sbtIO libraryDependencies += sbtIO
) )
// Internal utility for testing
lazy val utilTesting = (project in internalPath / "util-testing").
settings(
commonSettings,
name := "Util Testing",
libraryDependencies ++= Seq(scalaCheck, scalatest)
)
def customCommands: Seq[Setting[_]] = Seq(
commands += Command.command("release") { state =>
// "clean" ::
"so compile" ::
"so publishSigned" ::
"reload" ::
state
}
)

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import scala.reflect._ import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import scala.reflect._ import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import Classes.Applicative import Classes.Applicative

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import Types.Id import Types.Id

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import scala.reflect._ import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import Types.Id import Types.Id

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package appmacro package appmacro
import Types.Id import Types.Id

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah * Copyright 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, Output => Out } import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, Output => Out }
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream } import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah * Copyright 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import java.io.{ File, FileNotFoundException } import java.io.{ File, FileNotFoundException }
import sbinary.{ DefaultProtocol, Format, Operations } import sbinary.{ DefaultProtocol, Format, Operations }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah * Copyright 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import java.io.{ File, IOException } import java.io.{ File, IOException }
import sbinary.{ DefaultProtocol, Format } import sbinary.{ DefaultProtocol, Format }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah * Copyright 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types.:+: import Types.:+:
import sbinary.{ DefaultProtocol, Format, Input, Output => Out } import sbinary.{ DefaultProtocol, Format, Input, Output => Out }

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import java.io.File import java.io.File
import Types.:+: import Types.:+:

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import Classes.Applicative import Classes.Applicative
import Types._ import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._
import scala.reflect.Manifest import scala.reflect.Manifest

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
object Classes { object Classes {
trait Applicative[M[_]] { trait Applicative[M[_]] {

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 David MacIver, Mark Harrah * Copyright 2008, 2009, 2010 David MacIver, Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
trait Dag[Node <: Dag[Node]] { trait Dag[Node <: Dag[Node]] {
self: Node => self: Node =>

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
/** A mutable set interface that uses object identity to test for set membership.*/ /** A mutable set interface that uses object identity to test for set membership.*/
trait IDSet[T] { trait IDSet[T] {

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import java.lang.Runnable import java.lang.Runnable
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue } import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import Types._ import Types._
import Classes.Applicative import Classes.Applicative

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import collection.mutable import collection.mutable

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
sealed trait SourcePosition sealed trait SourcePosition

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah * Copyright 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
trait Show[T] { trait Show[T] {
def apply(t: T): String def apply(t: T): String

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
trait ShowLines[A] { trait ShowLines[A] {
def showLines(a: A): Seq[String] def showLines(a: A): Seq[String]

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
object Signals { object Signals {
val CONT = "CONT" val CONT = "CONT"

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
trait TypeFunctions { trait TypeFunctions {
type Id[X] = X type Id[X] = X

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
object Types extends Types object Types extends Types

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah * Copyright 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import java.util.Locale import java.util.Locale

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008 Mark Harrah */ * Copyright 2008 Mark Harrah */
package sbt.util.internal package sbt.internal.util
import org.scalacheck._ import org.scalacheck._
import Prop._ import Prop._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import org.scalacheck._ import org.scalacheck._
import Prop._ import Prop._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Types._ import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
/** Define our settings system */ /** Define our settings system */

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import org.scalacheck._ import org.scalacheck._
import Prop._ import Prop._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah * Copyright 2008, 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import jline.console.ConsoleReader import jline.console.ConsoleReader
import jline.console.history.{ FileHistory, MemoryHistory } import jline.console.history.{ FileHistory, MemoryHistory }
@ -128,7 +128,7 @@ final class FullReader(historyPath: Option[File], complete: Parser[_], val handl
protected[this] val reader = protected[this] val reader =
{ {
val cr = JLine.createReader(historyPath) val cr = JLine.createReader(historyPath)
sbt.util.internal.complete.JLineCompletion.installCustomCompletor(cr, complete) sbt.internal.util.complete.JLineCompletion.installCustomCompletor(cr, complete)
cr cr
} }
} }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
/** /**

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import java.lang.Character.{ toLowerCase => lower } import java.lang.Character.{ toLowerCase => lower }

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import java.io.File import java.io.File

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
import History.number import History.number

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
import java.io.File import java.io.File

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah * Copyright 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
import jline.console.ConsoleReader import jline.console.ConsoleReader

View File

@ -1,12 +1,12 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2010, 2011 Mark Harrah * Copyright 2008, 2010, 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
import Parser._ import Parser._
import sbt.util.internal.Types.{ left, right, some } import sbt.internal.util.Types.{ left, right, some }
import sbt.util.internal.Util.{ makeList, separate } import sbt.internal.util.Util.{ makeList, separate }
/** /**
* A String parser that provides semi-automatic tab completion. * A String parser that provides semi-automatic tab completion.

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah * Copyright 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
import Parser._ import Parser._

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
object ProcessError { object ProcessError {

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import Completion.{ token => ctoken, tokenDisplay } import Completion.{ token => ctoken, tokenDisplay }

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import DefaultParsers._ import DefaultParsers._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008,2010 Mark Harrah * Copyright 2008,2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
package complete package complete
sealed trait UpperBound { sealed trait UpperBound {

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
object JLineTest { object JLineTest {

View File

@ -1,54 +1,60 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import java.io.File import java.io.File
import sbt.io.IO._ import sbt.io.IO._
class FileExamplesTest extends Specification { class FileExamplesTest extends UnitSpec {
"listing all files in an absolute base directory" should { "listing all files in an absolute base directory" should
"produce the entire base directory's contents" in new directoryStructure { "produce the entire base directory's contents" in {
fileExamples().toList should containTheSameElementsAs(allRelativizedPaths) val _ = new DirectoryStructure {
fileExamples().toList should contain theSameElementsAs (allRelativizedPaths)
}
}
"listing files with a prefix that matches none" should
"produce an empty list" in {
val _ = new DirectoryStructure(withCompletionPrefix = "z") {
fileExamples().toList shouldBe empty
}
}
"listing single-character prefixed files" should
"produce matching paths only" in {
val _ = new DirectoryStructure(withCompletionPrefix = "f") {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
"listing directory-prefixed files" should
"produce matching paths only" in {
val _ = new DirectoryStructure(withCompletionPrefix = "far") {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
it should "produce sub-dir contents only when appending a file separator to the directory" in {
val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator) {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
} }
} }
"listing files with a prefix that matches none" should { "listing files with a sub-path prefix" should
"produce an empty list" in new directoryStructure(withCompletionPrefix = "z") { "produce matching paths only" in {
fileExamples().toList should beEmpty val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
} fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
} }
"listing single-character prefixed files" should {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "f") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
}
}
"listing directory-prefixed files" should {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
} }
"produce sub-dir contents only when appending a file separator to the directory" in new directoryStructure(withCompletionPrefix = "far" + File.separator) { "completing a full path" should
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly) "produce a list with an empty string" in {
val _ = new DirectoryStructure(withCompletionPrefix = "bazaar") {
fileExamples().toList shouldEqual List("")
}
} }
}
"listing files with a sub-path prefix" should { class DirectoryStructure(withCompletionPrefix: String = "") extends DelayedInit {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
}
}
"completing a full path" should {
"produce a list with an empty string" in new directoryStructure(withCompletionPrefix = "bazaar") {
fileExamples().toList shouldEqual List("")
}
}
class directoryStructure(withCompletionPrefix: String = "") extends Scope with DelayedInit {
var fileExamples: FileExamples = _ var fileExamples: FileExamples = _
var baseDir: File = _ var baseDir: File = _
var childFiles: List[File] = _ var childFiles: List[File] = _

View File

@ -1,26 +1,23 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import org.specs2.mutable.Specification class FixedSetExamplesTest extends UnitSpec {
import org.specs2.specification.Scope
class FixedSetExamplesTest extends Specification { "adding a prefix" should "produce a smaller set of examples with the prefix removed" in {
val _ = new Examples {
"adding a prefix" should { fixedSetExamples.withAddedPrefix("f")() should contain theSameElementsAs (List("oo", "ool", "u"))
"produce a smaller set of examples with the prefix removed" in new examples { fixedSetExamples.withAddedPrefix("fo")() should contain theSameElementsAs (List("o", "ol"))
fixedSetExamples.withAddedPrefix("f")() must containTheSameElementsAs(List("oo", "ool", "u")) fixedSetExamples.withAddedPrefix("b")() should contain theSameElementsAs (List("ar"))
fixedSetExamples.withAddedPrefix("fo")() must containTheSameElementsAs(List("o", "ol"))
fixedSetExamples.withAddedPrefix("b")() must containTheSameElementsAs(List("ar"))
} }
} }
"without a prefix" should { "without a prefix" should "produce the original set" in {
"produce the original set" in new examples { val _ = new Examples {
fixedSetExamples() mustEqual exampleSet fixedSetExamples() shouldBe exampleSet
} }
} }
trait examples extends Scope { trait Examples {
val exampleSet = List("foo", "bar", "fool", "fu") val exampleSet = List("foo", "bar", "fool", "fu")
val fixedSetExamples = FixedSetExamples(exampleSet) val fixedSetExamples = FixedSetExamples(exampleSet)
} }

View File

@ -1,61 +1,64 @@
package sbt.util.internal package sbt.internal.util
package complete package complete
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import Completion._ import Completion._
class ParserWithExamplesTest extends Specification { class ParserWithExamplesTest extends UnitSpec {
"listing a limited number of completions" should { "listing a limited number of completions" should
"grab only the needed number of elements from the iterable source of examples" in new parserWithLazyExamples { "grab only the needed number of elements from the iterable source of examples" in {
parserWithExamples.completions(0) val _ = new ParserWithLazyExamples {
examples.size shouldEqual maxNumberOfExamples parserWithExamples.completions(0)
examples.size shouldEqual maxNumberOfExamples
}
} }
}
"listing only valid completions" should { "listing only valid completions" should
"use the delegate parser to remove invalid examples" in new parserWithValidExamples { "use the delegate parser to remove invalid examples" in {
val validCompletions = Completions(Set( val _ = new ParserWithValidExamples {
suggestion("blue"), val validCompletions = Completions(Set(
suggestion("red"))) suggestion("blue"),
parserWithExamples.completions(0) shouldEqual validCompletions suggestion("red")))
parserWithExamples.completions(0) shouldEqual validCompletions
}
} }
}
"listing valid completions in a derived parser" should { "listing valid completions in a derived parser" should
"produce only valid examples that start with the character of the derivation" in new parserWithValidExamples { "produce only valid examples that start with the character of the derivation" in {
val derivedCompletions = Completions(Set( val _ = new ParserWithValidExamples {
suggestion("lue"))) val derivedCompletions = Completions(Set(
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions suggestion("lue")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
} }
}
"listing valid and invalid completions" should { "listing valid and invalid completions" should
"produce the entire source of examples" in new parserWithAllExamples { "produce the entire source of examples" in {
val completions = Completions(examples.map(suggestion(_)).toSet) val _ = new parserWithAllExamples {
parserWithExamples.completions(0) shouldEqual completions val completions = Completions(examples.map(suggestion(_)).toSet)
parserWithExamples.completions(0) shouldEqual completions
}
} }
}
"listing valid and invalid completions in a derived parser" should { "listing valid and invalid completions in a derived parser" should
"produce only examples that start with the character of the derivation" in new parserWithAllExamples { "produce only examples that start with the character of the derivation" in {
val derivedCompletions = Completions(Set( val _ = new parserWithAllExamples {
suggestion("lue"), val derivedCompletions = Completions(Set(
suggestion("lock"))) suggestion("lue"),
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions suggestion("lock")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
} }
}
class parserWithLazyExamples extends parser(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false) class ParserWithLazyExamples extends ParserExample(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false)
class parserWithValidExamples extends parser(removeInvalidExamples = true) class ParserWithValidExamples extends ParserExample(removeInvalidExamples = true)
class parserWithAllExamples extends parser(removeInvalidExamples = false) class parserWithAllExamples extends ParserExample(removeInvalidExamples = false)
case class parser(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"), case class ParserExample(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
maxNumberOfExamples: Int = 25, maxNumberOfExamples: Int = 25,
removeInvalidExamples: Boolean) extends Scope { removeInvalidExamples: Boolean) {
import DefaultParsers._ import DefaultParsers._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah * Copyright 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import java.io.IOException import java.io.IOException

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah * Copyright 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
/** Defines a function to call as sbt exits.*/ /** Defines a function to call as sbt exits.*/
trait ExitHook { trait ExitHook {

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah * Copyright 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
final class MessageOnlyException(override val toString: String) extends RuntimeException(toString) final class MessageOnlyException(override val toString: String) extends RuntimeException(toString)

View File

@ -1,17 +1,19 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
/** Implements the level-setting methods of Logger.*/ /** Implements the level-setting methods of Logger.*/
abstract class BasicLogger extends AbstractLogger { abstract class BasicLogger extends AbstractLogger {
private var traceEnabledVar = java.lang.Integer.MAX_VALUE private var traceEnabledVar: Int = java.lang.Integer.MAX_VALUE
private var level: Level.Value = Level.Info private var level: Level.Value = Level.Info
private var successEnabledVar = true private var successEnabledVar = true
def successEnabled = synchronized { successEnabledVar } def successEnabled: Boolean = synchronized { successEnabledVar }
def setSuccessEnabled(flag: Boolean): Unit = synchronized { successEnabledVar = flag } def setSuccessEnabled(flag: Boolean): Unit = synchronized { successEnabledVar = flag }
def getLevel = synchronized { level } def getLevel: Level.Value = synchronized { level }
def setLevel(newLevel: Level.Value): Unit = synchronized { level = newLevel } def setLevel(newLevel: Level.Value): Unit = synchronized { level = newLevel }
def setTrace(level: Int): Unit = synchronized { traceEnabledVar = level } def setTrace(level: Int): Unit = synchronized { traceEnabledVar = level }
def getTrace = synchronized { traceEnabledVar } def getTrace: Int = synchronized { traceEnabledVar }
} }

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
/** /**

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010, 2011 Mark Harrah * Copyright 2008, 2009, 2010, 2011 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
import java.io.{ BufferedWriter, PrintStream, PrintWriter } import java.io.{ BufferedWriter, PrintStream, PrintWriter }
import java.util.Locale import java.util.Locale

View File

@ -1,5 +1,6 @@
package sbt.util.internal package sbt.internal.util
import sbt.util._
import java.io.{ BufferedWriter, PrintStream, PrintWriter } import java.io.{ BufferedWriter, PrintStream, PrintWriter }
sealed trait ConsoleOut { sealed trait ConsoleOut {

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
/** /**
* A filter logger is used to delegate messages but not the logging level to another logger. This means * A filter logger is used to delegate messages but not the logging level to another logger. This means

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
/** Promotes the simple Logger interface to the full AbstractLogger interface. */ /** Promotes the simple Logger interface to the full AbstractLogger interface. */
class FullLogger(delegate: Logger) extends BasicLogger { class FullLogger(delegate: Logger) extends BasicLogger {

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
import java.io.{ File, PrintWriter } import java.io.{ File, PrintWriter }
/** /**

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
/** /**
* Provides a `java.io.Writer` interface to a `Logger`. Content is line-buffered and logged at `level`. * Provides a `java.io.Writer` interface to a `Logger`. Content is line-buffered and logged at `level`.

View File

@ -1,5 +1,6 @@
package sbt.util.internal package sbt.internal.util
import sbt.util._
import java.io.PrintWriter import java.io.PrintWriter
object MainLogging { object MainLogging {

View File

@ -2,7 +2,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import sbt.util._
// note that setting the logging level on this logger has no effect on its behavior, only // note that setting the logging level on this logger has no effect on its behavior, only
// on the behavior of the delegates. // on the behavior of the delegates.

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Tony Sloane * Copyright 2010 Tony Sloane
*/ */
package sbt.util.internal package sbt.internal.util
object StackTrace { object StackTrace {
def isSbtClass(name: String) = name.startsWith("sbt") || name.startsWith("xsbt") def isSbtClass(name: String) = name.startsWith("sbt") || name.startsWith("xsbt")

View File

@ -0,0 +1,28 @@
package sbt.util
abstract class AbstractLogger extends Logger {
def getLevel: Level.Value
def setLevel(newLevel: Level.Value): Unit
def setTrace(flag: Int): Unit
def getTrace: Int
final def traceEnabled: Boolean = getTrace >= 0
def successEnabled: Boolean
def setSuccessEnabled(flag: Boolean): Unit
def atLevel(level: Level.Value): Boolean = level.id >= getLevel.id
def control(event: ControlEvent.Value, message: => String): Unit
def logAll(events: Seq[LogEvent]): Unit
/** Defined in terms of other methods in Logger and should not be called from them. */
final def log(event: LogEvent): Unit = {
event match {
case s: Success => success(s.msg)
case l: Log => log(l.level, l.msg)
case t: Trace => trace(t.exception)
case setL: SetLevel => setLevel(setL.newLevel)
case setT: SetTrace => setTrace(setT.level)
case setS: SetSuccess => setSuccessEnabled(setS.enabled)
case c: ControlEvent => control(c.event, c.msg)
}
}
}

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah * Copyright 2008, 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.util
/** /**
* An enumeration defining the levels available for logging. A level includes all of the levels * An enumeration defining the levels available for logging. A level includes all of the levels

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah * Copyright 2008, 2009 Mark Harrah
*/ */
package sbt.util.internal package sbt.util
sealed trait LogEvent extends NotNull sealed trait LogEvent extends NotNull
final class Success(val msg: String) extends LogEvent final class Success(val msg: String) extends LogEvent

View File

@ -1,39 +1,42 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah * Copyright 2008, 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.util
import xsbti.{ Logger => xLogger, F0 } import xsbti.{ Logger => xLogger, F0 }
import xsbti.{ Maybe, Position, Problem, Severity } import xsbti.{ Maybe, Position, Problem, Severity }
import sys.process.ProcessLogger import sys.process.ProcessLogger
import sbt.internal.util.{ BufferedLogger, FullLogger }
import java.io.File import java.io.File
abstract class AbstractLogger extends Logger { /**
def getLevel: Level.Value * This is intended to be the simplest logging interface for use by code that wants to log.
def setLevel(newLevel: Level.Value): Unit * It does not include configuring the logger.
def setTrace(flag: Int): Unit */
def getTrace: Int abstract class Logger extends xLogger {
final def traceEnabled: Boolean = getTrace >= 0 final def verbose(message: => String): Unit = debug(message)
def successEnabled: Boolean final def debug(message: => String): Unit = log(Level.Debug, message)
def setSuccessEnabled(flag: Boolean): Unit final def info(message: => String): Unit = log(Level.Info, message)
final def warn(message: => String): Unit = log(Level.Warn, message)
final def error(message: => String): Unit = log(Level.Error, message)
// Added by sys.process.ProcessLogger
final def err(message: => String): Unit = log(Level.Error, message)
// sys.process.ProcessLogger
final def out(message: => String): Unit = log(Level.Info, message)
def atLevel(level: Level.Value): Boolean = level.id >= getLevel.id def ansiCodesSupported: Boolean = false
def control(event: ControlEvent.Value, message: => String): Unit
def logAll(events: Seq[LogEvent]): Unit def trace(t: => Throwable): Unit
/** Defined in terms of other methods in Logger and should not be called from them. */ def success(message: => String): Unit
final def log(event: LogEvent): Unit = { def log(level: Level.Value, message: => String): Unit
event match {
case s: Success => success(s.msg) def debug(msg: F0[String]): Unit = log(Level.Debug, msg)
case l: Log => log(l.level, l.msg) def warn(msg: F0[String]): Unit = log(Level.Warn, msg)
case t: Trace => trace(t.exception) def info(msg: F0[String]): Unit = log(Level.Info, msg)
case setL: SetLevel => setLevel(setL.newLevel) def error(msg: F0[String]): Unit = log(Level.Error, msg)
case setT: SetTrace => setTrace(setT.level) def trace(msg: F0[Throwable]): Unit = trace(msg.apply)
case setS: SetSuccess => setSuccessEnabled(setS.enabled) def log(level: Level.Value, msg: F0[String]): Unit = log(level, msg.apply)
case c: ControlEvent => control(c.event, c.msg)
}
}
} }
object Logger { object Logger {
@ -107,32 +110,3 @@ object Logger {
override def toString = s"[$severity] $pos: $message" override def toString = s"[$severity] $pos: $message"
} }
} }
/**
* This is intended to be the simplest logging interface for use by code that wants to log.
* It does not include configuring the logger.
*/
trait Logger extends xLogger {
final def verbose(message: => String): Unit = debug(message)
final def debug(message: => String): Unit = log(Level.Debug, message)
final def info(message: => String): Unit = log(Level.Info, message)
final def warn(message: => String): Unit = log(Level.Warn, message)
final def error(message: => String): Unit = log(Level.Error, message)
// Added by sys.process.ProcessLogger
final def err(message: => String): Unit = log(Level.Error, message)
// sys.process.ProcessLogger
final def out(message: => String): Unit = log(Level.Info, message)
def ansiCodesSupported: Boolean = false
def trace(t: => Throwable): Unit
def success(message: => String): Unit
def log(level: Level.Value, message: => String): Unit
def debug(msg: F0[String]): Unit = log(Level.Debug, msg)
def warn(msg: F0[String]): Unit = log(Level.Warn, msg)
def info(msg: F0[String]): Unit = log(Level.Info, msg)
def error(msg: F0[String]): Unit = log(Level.Error, msg)
def trace(msg: F0[Throwable]): Unit = trace(msg.apply)
def log(level: Level.Value, msg: F0[String]): Unit = log(level, msg.apply)
}

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
import org.scalacheck._ import org.scalacheck._
import Prop._ import Prop._
@ -61,6 +61,7 @@ object Escapes extends Properties("Escapes") {
final case class EscapeAndNot(escape: EscapeSequence, notEscape: String) { final case class EscapeAndNot(escape: EscapeSequence, notEscape: String) {
override def toString = s"EscapeAntNot(escape = [$escape], notEscape = [${notEscape.map(_.toInt)}])" override def toString = s"EscapeAntNot(escape = [$escape], notEscape = [${notEscape.map(_.toInt)}])"
} }
// 2.10.5 warns on "implicit numeric widening" but it looks like a bug: https://issues.scala-lang.org/browse/SI-8450
final case class EscapeSequence(content: String, terminator: Char) { final case class EscapeSequence(content: String, terminator: Char) {
if (!content.isEmpty) { if (!content.isEmpty) {
assert(content.tail.forall(c => !isEscapeTerminator(c)), "Escape sequence content contains an escape terminator: '" + content + "'") assert(content.tail.forall(c => !isEscapeTerminator(c)), "Escape sequence content contains an escape terminator: '" + content + "'")

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah */ * Copyright 2010 Mark Harrah */
package sbt.util.internal package sbt.internal.util
import sbt.util._
import org.scalacheck._ import org.scalacheck._
import Arbitrary.{ arbitrary => arb, _ } import Arbitrary.{ arbitrary => arb, _ }
import Gen.{ listOfN, oneOf } import Gen.{ listOfN, oneOf }

View File

@ -1,4 +1,6 @@
package sbt.util.internal package sbt.internal.util
import sbt.util._
object TestLogger { object TestLogger {
def apply[T](f: Logger => T): T = def apply[T](f: Logger => T): T =

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package logic package logic
import scala.annotation.tailrec import scala.annotation.tailrec

View File

@ -1,4 +1,4 @@
package sbt.util.internal package sbt.internal.util
package logic package logic
import org.scalacheck._ import org.scalacheck._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import Relation._ import Relation._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah * Copyright 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import org.scalacheck._ import org.scalacheck._
import Prop._ import Prop._

View File

@ -0,0 +1,5 @@
package sbt.internal.util
import org.scalatest._
abstract class UnitSpec extends FlatSpec with Matchers

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah * Copyright 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
object ChangeReport { object ChangeReport {
def modified[T](files: Set[T]): ChangeReport[T] = def modified[T](files: Set[T]): ChangeReport[T] =

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool /* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah * Copyright 2009, 2010 Mark Harrah
*/ */
package sbt.util.internal package sbt.internal.util
import java.io.{ File, IOException } import java.io.{ File, IOException }
import CacheIO.{ fromFile, toFile } import CacheIO.{ fromFile, toFile }

View File

@ -5,7 +5,7 @@ object Dependencies {
lazy val scala210 = "2.10.5" lazy val scala210 = "2.10.5"
lazy val scala211 = "2.11.7" lazy val scala211 = "2.11.7"
lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M1" lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M3"
lazy val jline = "jline" % "jline" % "2.11" lazy val jline = "jline" % "jline" % "2.11"
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.2" lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.2"
lazy val sbinary = "org.scala-tools.sbinary" %% "sbinary" % "0.4.2" lazy val sbinary = "org.scala-tools.sbinary" %% "sbinary" % "0.4.2"
@ -23,10 +23,6 @@ object Dependencies {
lazy val scalaXml = scala211Module("scala-xml", "1.0.1") lazy val scalaXml = scala211Module("scala-xml", "1.0.1")
lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4" lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.12.4"
lazy val specs2 = "org.specs2" %% "specs2" % "2.3.11" lazy val scalatest = "org.scalatest" %% "scalatest" % "2.2.4"
lazy val testDependencies = libraryDependencies ++= Seq(
scalaCheck,
specs2
).map(_ % "test")
} }

View File

@ -7,8 +7,10 @@ object Util {
lazy val generateKeywords = TaskKey[File]("generateKeywords") lazy val generateKeywords = TaskKey[File]("generateKeywords")
lazy val javaOnlySettings = Seq[Setting[_]]( lazy val javaOnlySettings = Seq[Setting[_]](
crossPaths := false,
compileOrder := CompileOrder.JavaThenScala, compileOrder := CompileOrder.JavaThenScala,
unmanagedSourceDirectories in Compile <<= Seq(javaSource in Compile).join unmanagedSourceDirectories in Compile <<= Seq(javaSource in Compile).join,
crossScalaVersions := Seq(Dependencies.scala211)
) )
def getScalaKeywords: Set[String] = def getScalaKeywords: Set[String] =
@ -20,7 +22,7 @@ object Util {
{ {
val init = keywords.map(tn => '"' + tn + '"').mkString("Set(", ", ", ")") val init = keywords.map(tn => '"' + tn + '"').mkString("Set(", ", ", ")")
val ObjectName = "ScalaKeywords" val ObjectName = "ScalaKeywords"
val PackageName = "sbt.util.internal" val PackageName = "sbt.internal.util"
val keywordsSrc = val keywordsSrc =
"""package %s """package %s
object %s { object %s {

1
project/doge.sbt Normal file
View File

@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.3")