From 0c08c1169e478d9e46323f6e074c5dedbca4ffe3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 4 Dec 2012 12:19:14 -0500 Subject: [PATCH] Bumped the Scalatest/Specs versions for 2.10.0-RC3 * Modified tests to use mutable Specs API * Fixed a few minor specs issues. --- ivy/src/test/scala/ComponentManagerTest.scala | 5 ++-- launch/src/test/scala/ScalaProviderTest.scala | 24 +++++++++---------- main/src/test/scala/TagsTest.scala | 15 +++++++----- project/Util.scala | 4 ++-- util/io/src/test/scala/StashSpec.scala | 7 +++--- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/ivy/src/test/scala/ComponentManagerTest.scala b/ivy/src/test/scala/ComponentManagerTest.scala index 1d9e77c44..a9bbe051f 100644 --- a/ivy/src/test/scala/ComponentManagerTest.scala +++ b/ivy/src/test/scala/ComponentManagerTest.scala @@ -1,7 +1,8 @@ package sbt import java.io.File -import org.specs._ +import org.specs2._ +import mutable.Specification import IO.{createDirectory, delete, touch, withTemporaryDirectory} import org.apache.ivy.util.ChecksumHelper import IfMissing.Fail @@ -78,4 +79,4 @@ object ComponentManagerTest extends Specification private def randomString = "asdf" 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)) } ) -} \ No newline at end of file +} diff --git a/launch/src/test/scala/ScalaProviderTest.scala b/launch/src/test/scala/ScalaProviderTest.scala index ae5e5dfe2..a99bf1e01 100644 --- a/launch/src/test/scala/ScalaProviderTest.scala +++ b/launch/src/test/scala/ScalaProviderTest.scala @@ -4,30 +4,30 @@ import java.io.{File,InputStream} import java.net.URL import java.util.Properties import xsbti._ -import org.specs._ +import org.specs2._ +import mutable.Specification import LaunchTest._ import sbt.IO.{createDirectory, touch,withTemporaryDirectory} object ScalaProviderTest extends Specification { - def provide = addToSusVerb("provide") - "Launch" should provide { - "ClassLoader for Scala 2.8.0" in { checkScalaLoader("2.8.0") } - "ClassLoader for Scala 2.8.2" in { checkScalaLoader("2.8.2") } - "ClassLoader for Scala 2.9.0" in { checkScalaLoader("2.9.0") } - "ClassLoader for Scala 2.9.2" in { checkScalaLoader("2.9.2") } + "Launch" should { + "provide ClassLoader for Scala 2.8.0" in { checkScalaLoader("2.8.0") } + "provide ClassLoader for Scala 2.8.2" in { checkScalaLoader("2.8.2") } + "provide ClassLoader for Scala 2.9.0" in { checkScalaLoader("2.9.0") } + "provide ClassLoader for Scala 2.9.2" in { checkScalaLoader("2.9.2") } } "Launch" should { "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] } "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 { - 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, extra: Array[File]): Application = Application("org.scala-sbt", "launch-test", new Explicit(AppVersion), main, Nil, false, extra) 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 = withTemporaryDirectory { bootDirectory => f(Launcher(bootDirectory, testRepositories)) @@ -86,4 +86,4 @@ object LaunchTest try { properties.load(propertiesStream) } finally { propertiesStream.close() } properties } -} \ No newline at end of file +} diff --git a/main/src/test/scala/TagsTest.scala b/main/src/test/scala/TagsTest.scala index 6f8c5da8e..85be939b2 100644 --- a/main/src/test/scala/TagsTest.scala +++ b/main/src/test/scala/TagsTest.scala @@ -1,22 +1,25 @@ package sbt import org.scalacheck._ -import Gen.{genInt,listOf,genString} +import Gen.{listOf} import Prop.forAll import Tags._ object TagsTest extends Properties("Tags") { 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 tag: Gen[Tag] = for(s <- genString) yield Tag(s) + def tagAndFrequency: Gen[(Tag, Int)] = for(t <- tag; count <- Arbitrary.arbitrary[Int]) yield (t, count) + 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) => 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) => - val tm: TagMap = tm.updated(etag, math.abs(size)) - excl(etag)(tm) == (size <= 1) + val tm2: TagMap = tm.updated(etag, math.abs(size)) + excl(etag)(tm2) == (size <= 1) } property("exclusive always allows a group of size one") = forAll { (etag: Tag, mapTag: Tag) => 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) -} \ No newline at end of file +} diff --git a/project/Util.scala b/project/Util.scala index ed9023afd..896122a7f 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -30,8 +30,8 @@ object Util lazy val base: Seq[Setting[_]] = Seq(scalacOptions ++= Seq("-Xelide-below", "0"), projectComponent) ++ Licensed.settings def testDependencies = libraryDependencies ++= Seq( - "org.scalacheck" % "scalacheck_2.10.0-M5" % "1.10.0" % "test", - "org.scala-tools.testing" % "specs_2.9.1" % "1.6.9" % "test" + "org.scalacheck" % "scalacheck_2.10.0-RC3" % "1.10.0" % "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)) diff --git a/util/io/src/test/scala/StashSpec.scala b/util/io/src/test/scala/StashSpec.scala index 6f3fe2841..c50f81eb1 100644 --- a/util/io/src/test/scala/StashSpec.scala +++ b/util/io/src/test/scala/StashSpec.scala @@ -3,7 +3,8 @@ package sbt -import org.specs._ +import org.specs2._ +import mutable.Specification import IO._ import java.io.File @@ -62,7 +63,7 @@ object CheckStash extends Specification def correct(check: File, ref: (File, String)) = { 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 @@ -79,4 +80,4 @@ object CheckStash extends Specification } class TestError extends Error class TestRuntimeException extends RuntimeException -class TestException extends Exception \ No newline at end of file +class TestException extends Exception