mirror of https://github.com/sbt/sbt.git
Bumped the Scalatest/Specs versions for 2.10.0-RC3
* Modified tests to use mutable Specs API * Fixed a few minor specs issues.
This commit is contained in:
parent
cdd2e72cdf
commit
0c08c1169e
|
|
@ -1,7 +1,8 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import org.specs._
|
import org.specs2._
|
||||||
|
import mutable.Specification
|
||||||
import IO.{createDirectory, delete, touch, withTemporaryDirectory}
|
import IO.{createDirectory, delete, touch, withTemporaryDirectory}
|
||||||
import org.apache.ivy.util.ChecksumHelper
|
import org.apache.ivy.util.ChecksumHelper
|
||||||
import IfMissing.Fail
|
import IfMissing.Fail
|
||||||
|
|
@ -78,4 +79,4 @@ object ComponentManagerTest extends Specification
|
||||||
private def randomString = "asdf"
|
private def randomString = "asdf"
|
||||||
private def withManager[T](f: ComponentManager => T): T =
|
private def withManager[T](f: ComponentManager => T): T =
|
||||||
TestLogger( logger => withTemporaryDirectory { temp => f(new ComponentManager(xsbt.boot.Locks, new xsbt.boot.ComponentProvider(temp, true), None, logger)) } )
|
TestLogger( logger => withTemporaryDirectory { temp => f(new ComponentManager(xsbt.boot.Locks, new xsbt.boot.ComponentProvider(temp, true), None, logger)) } )
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,30 @@ import java.io.{File,InputStream}
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import xsbti._
|
import xsbti._
|
||||||
import org.specs._
|
import org.specs2._
|
||||||
|
import mutable.Specification
|
||||||
import LaunchTest._
|
import LaunchTest._
|
||||||
import sbt.IO.{createDirectory, touch,withTemporaryDirectory}
|
import sbt.IO.{createDirectory, touch,withTemporaryDirectory}
|
||||||
|
|
||||||
object ScalaProviderTest extends Specification
|
object ScalaProviderTest extends Specification
|
||||||
{
|
{
|
||||||
def provide = addToSusVerb("provide")
|
"Launch" should {
|
||||||
"Launch" should provide {
|
"provide ClassLoader for Scala 2.8.0" in { checkScalaLoader("2.8.0") }
|
||||||
"ClassLoader for Scala 2.8.0" in { checkScalaLoader("2.8.0") }
|
"provide ClassLoader for Scala 2.8.2" in { checkScalaLoader("2.8.2") }
|
||||||
"ClassLoader for Scala 2.8.2" in { checkScalaLoader("2.8.2") }
|
"provide ClassLoader for Scala 2.9.0" in { checkScalaLoader("2.9.0") }
|
||||||
"ClassLoader for Scala 2.9.0" in { checkScalaLoader("2.9.0") }
|
"provide ClassLoader for Scala 2.9.2" in { checkScalaLoader("2.9.2") }
|
||||||
"ClassLoader for Scala 2.9.2" in { checkScalaLoader("2.9.2") }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"Launch" should {
|
"Launch" should {
|
||||||
"Successfully load an application from local repository and run it with correct arguments" in {
|
"Successfully load an application from local repository and run it with correct arguments" in {
|
||||||
checkLoad(List("test"), "xsbt.boot.test.ArgumentTest").asInstanceOf[Exit].code must be(0)
|
checkLoad(List("test"), "xsbt.boot.test.ArgumentTest").asInstanceOf[Exit].code must equalTo(0)
|
||||||
checkLoad(List(), "xsbt.boot.test.ArgumentTest") must throwA[RuntimeException]
|
checkLoad(List(), "xsbt.boot.test.ArgumentTest") must throwA[RuntimeException]
|
||||||
}
|
}
|
||||||
"Successfully load an application from local repository and run it with correct sbt version" in {
|
"Successfully load an application from local repository and run it with correct sbt version" in {
|
||||||
checkLoad(List(AppVersion), "xsbt.boot.test.AppVersionTest").asInstanceOf[Exit].code must be(0)
|
checkLoad(List(AppVersion), "xsbt.boot.test.AppVersionTest").asInstanceOf[Exit].code must equalTo(0)
|
||||||
}
|
}
|
||||||
"Add extra resources to the classpath" in {
|
"Add extra resources to the classpath" in {
|
||||||
checkLoad(testResources, "xsbt.boot.test.ExtraTest", createExtra).asInstanceOf[Exit].code must be(0)
|
checkLoad(testResources, "xsbt.boot.test.ExtraTest", createExtra).asInstanceOf[Exit].code must equalTo(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ object LaunchTest
|
||||||
def testApp(main: String): Application = testApp(main, Array[File]())
|
def testApp(main: String): Application = testApp(main, Array[File]())
|
||||||
def testApp(main: String, extra: Array[File]): Application = Application("org.scala-sbt", "launch-test", new Explicit(AppVersion), main, Nil, false, extra)
|
def testApp(main: String, extra: Array[File]): Application = Application("org.scala-sbt", "launch-test", new Explicit(AppVersion), main, Nil, false, extra)
|
||||||
import Predefined._
|
import Predefined._
|
||||||
def testRepositories = List(Local, ScalaToolsReleases, ScalaToolsSnapshots).map(Repository.Predefined.apply)
|
def testRepositories = List(Local, ScalaToolsReleases, ScalaToolsSnapshots).map(Repository.Predefined(_))
|
||||||
def withLauncher[T](f: xsbti.Launcher => T): T =
|
def withLauncher[T](f: xsbti.Launcher => T): T =
|
||||||
withTemporaryDirectory { bootDirectory =>
|
withTemporaryDirectory { bootDirectory =>
|
||||||
f(Launcher(bootDirectory, testRepositories))
|
f(Launcher(bootDirectory, testRepositories))
|
||||||
|
|
@ -86,4 +86,4 @@ object LaunchTest
|
||||||
try { properties.load(propertiesStream) } finally { propertiesStream.close() }
|
try { properties.load(propertiesStream) } finally { propertiesStream.close() }
|
||||||
properties
|
properties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,25 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import org.scalacheck._
|
import org.scalacheck._
|
||||||
import Gen.{genInt,listOf,genString}
|
import Gen.{listOf}
|
||||||
import Prop.forAll
|
import Prop.forAll
|
||||||
import Tags._
|
import Tags._
|
||||||
|
|
||||||
object TagsTest extends Properties("Tags")
|
object TagsTest extends Properties("Tags")
|
||||||
{
|
{
|
||||||
def tagMap: Gen[TagMap] = for(ts <- listOf(tagAndFrequency)) yield ts.toMap
|
def tagMap: Gen[TagMap] = for(ts <- listOf(tagAndFrequency)) yield ts.toMap
|
||||||
def tagAndFrequency: Gen[(Tag, Int)] = for(t <- tag; count <- genInt) yield (t, count)
|
def tagAndFrequency: Gen[(Tag, Int)] = for(t <- tag; count <- Arbitrary.arbitrary[Int]) yield (t, count)
|
||||||
def tag: Gen[Tag] = for(s <- genString) yield Tag(s)
|
def tag: Gen[Tag] = for(s <- Arbitrary.arbitrary[String]) yield Tag(s)
|
||||||
|
implicit def aTagMap = Arbitrary(tagMap)
|
||||||
|
implicit def aTagAndFrequency = Arbitrary(tagAndFrequency)
|
||||||
|
implicit def aTag = Arbitrary(tag)
|
||||||
|
|
||||||
property("exclusive allows all groups without the exclusive tag") = forAll { (tm: TagMap, tag: Tag) =>
|
property("exclusive allows all groups without the exclusive tag") = forAll { (tm: TagMap, tag: Tag) =>
|
||||||
excl(tag)(tm - tag)
|
excl(tag)(tm - tag)
|
||||||
}
|
}
|
||||||
property("exclusive only allows a group with an excusive tag when the size is one") = forAll { (tm: TagMap, size: Int, etag: Tag) =>
|
property("exclusive only allows a group with an excusive tag when the size is one") = forAll { (tm: TagMap, size: Int, etag: Tag) =>
|
||||||
val tm: TagMap = tm.updated(etag, math.abs(size))
|
val tm2: TagMap = tm.updated(etag, math.abs(size))
|
||||||
excl(etag)(tm) == (size <= 1)
|
excl(etag)(tm2) == (size <= 1)
|
||||||
}
|
}
|
||||||
property("exclusive always allows a group of size one") = forAll { (etag: Tag, mapTag: Tag) =>
|
property("exclusive always allows a group of size one") = forAll { (etag: Tag, mapTag: Tag) =>
|
||||||
val tm: TagMap = Map(mapTag -> 1)
|
val tm: TagMap = Map(mapTag -> 1)
|
||||||
|
|
@ -25,4 +28,4 @@ object TagsTest extends Properties("Tags")
|
||||||
|
|
||||||
private[this] def excl(tag: Tag): TagMap => Boolean = predicate(exclusive(tag) :: Nil)
|
private[this] def excl(tag: Tag): TagMap => Boolean = predicate(exclusive(tag) :: Nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ object Util
|
||||||
lazy val base: Seq[Setting[_]] = Seq(scalacOptions ++= Seq("-Xelide-below", "0"), projectComponent) ++ Licensed.settings
|
lazy val base: Seq[Setting[_]] = Seq(scalacOptions ++= Seq("-Xelide-below", "0"), projectComponent) ++ Licensed.settings
|
||||||
|
|
||||||
def testDependencies = libraryDependencies ++= Seq(
|
def testDependencies = libraryDependencies ++= Seq(
|
||||||
"org.scalacheck" % "scalacheck_2.10.0-M5" % "1.10.0" % "test",
|
"org.scalacheck" % "scalacheck_2.10.0-RC3" % "1.10.0" % "test",
|
||||||
"org.scala-tools.testing" % "specs_2.9.1" % "1.6.9" % "test"
|
"org.specs2" % "specs2_2.10.0-RC3" % "1.12.3" % "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val minimalSettings: Seq[Setting[_]] = Defaults.paths ++ Seq[Setting[_]](crossTarget <<= target.identity, name <<= thisProject(_.id))
|
lazy val minimalSettings: Seq[Setting[_]] = Defaults.paths ++ Seq[Setting[_]](crossTarget <<= target.identity, name <<= thisProject(_.id))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import org.specs._
|
import org.specs2._
|
||||||
|
import mutable.Specification
|
||||||
|
|
||||||
import IO._
|
import IO._
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
@ -62,7 +63,7 @@ object CheckStash extends Specification
|
||||||
def correct(check: File, ref: (File, String)) =
|
def correct(check: File, ref: (File, String)) =
|
||||||
{
|
{
|
||||||
check.exists must beTrue
|
check.exists must beTrue
|
||||||
read(check) must beEqual(ref._2)
|
read(check) must equalTo(ref._2)
|
||||||
}
|
}
|
||||||
def noneExist(s: Seq[File]) = s.forall(!_.exists) must beTrue
|
def noneExist(s: Seq[File]) = s.forall(!_.exists) must beTrue
|
||||||
|
|
||||||
|
|
@ -79,4 +80,4 @@ object CheckStash extends Specification
|
||||||
}
|
}
|
||||||
class TestError extends Error
|
class TestError extends Error
|
||||||
class TestRuntimeException extends RuntimeException
|
class TestRuntimeException extends RuntimeException
|
||||||
class TestException extends Exception
|
class TestException extends Exception
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue