bump to util 0.1.0-M2 and migrated to scalatest

This commit is contained in:
Eugene Yokota 2015-09-05 05:32:07 -04:00
parent 734923fbae
commit dbf9dc7450
29 changed files with 473 additions and 506 deletions

View File

@ -40,7 +40,7 @@ lazy val root = (project in file(".")).
bintrayPackage := "librarymanagement" bintrayPackage := "librarymanagement"
)), )),
commonSettings, commonSettings,
// rootSettings, name := "LM Root",
publish := {}, publish := {},
publishLocal := {}, publishLocal := {},
publishArtifact := false publishArtifact := false
@ -49,8 +49,11 @@ lazy val root = (project in file(".")).
lazy val lm = (project in file("librarymanagement")). lazy val lm = (project in file("librarymanagement")).
settings( settings(
commonSettings, commonSettings,
libraryDependencies ++= Seq(utilLogging, utilLogging), libraryDependencies ++= Seq(
libraryDependencies ++= Seq(sbtIO, utilCollection, ivy, jsch, sbtSerialization, scalaReflect.value, launcherInterface), utilLogging, (utilLogging % Test).classifier("tests"),
sbtIO, (sbtIO % Test).classifier("tests"),
utilTesting % Test,
utilCollection, ivy, jsch, sbtSerialization, scalaReflect.value, launcherInterface),
resourceGenerators in Compile <+= (version, resourceManaged, streams, compile in Compile) map Util.generateVersionFile, resourceGenerators in Compile <+= (version, resourceManaged, streams, compile in Compile) map Util.generateVersionFile,
name := "librarymanagement" name := "librarymanagement"
) )

View File

@ -5,6 +5,7 @@ package sbt
import java.io.{ File, FileOutputStream } import java.io.{ File, FileOutputStream }
import java.util.concurrent.Callable import java.util.concurrent.Callable
import sbt.internal.util.Logger
/** /**
* A component manager provides access to the pieces of xsbt that are distributed as components. * A component manager provides access to the pieces of xsbt that are distributed as components.

View File

@ -1,6 +1,7 @@
package sbt package sbt
import DependencyFilter._ import DependencyFilter._
import sbt.internal.util.{ Logger, Level }
/** /**
* Provide warnings for cross version conflicts. * Provide warnings for cross version conflicts.

View File

@ -18,6 +18,7 @@ import java.io.{ IOException, File }
import org.apache.ivy.util.{ FileUtil, ChecksumHelper } import org.apache.ivy.util.{ FileUtil, ChecksumHelper }
import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact } import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact }
import sbt.io.IO import sbt.io.IO
import sbt.internal.util.Logger
private[sbt] object ConvertResolver { private[sbt] object ConvertResolver {
import UpdateOptions.ResolverConverter import UpdateOptions.ResolverConverter

View File

@ -6,6 +6,7 @@ package sbt
import java.io.File import java.io.File
import org.apache.ivy.util.url.CredentialsStore import org.apache.ivy.util.url.CredentialsStore
import sbt.io.IO import sbt.io.IO
import sbt.internal.util.Logger
object Credentials { object Credentials {
def apply(realm: String, host: String, userName: String, passwd: String): Credentials = def apply(realm: String, host: String, userName: String, passwd: String): Credentials =

View File

@ -3,6 +3,7 @@ package sbt
import collection.mutable import collection.mutable
import Configurations.Compile import Configurations.Compile
import ScalaArtifacts.{ LibraryID, CompilerID } import ScalaArtifacts.{ LibraryID, CompilerID }
import sbt.internal.util.{ Logger, ShowLines }
final class EvictionWarningOptions private[sbt] ( final class EvictionWarningOptions private[sbt] (
val configurations: Seq[Configuration], val configurations: Seq[Configuration],

View File

@ -39,6 +39,8 @@ import org.apache.ivy.util.extendable.ExtendableItem
import scala.xml.{ NodeSeq, Text } import scala.xml.{ NodeSeq, Text }
import scala.collection.mutable import scala.collection.mutable
import sbt.internal.util.Logger
final class IvySbt(val configuration: IvyConfiguration) { final class IvySbt(val configuration: IvyConfiguration) {
import configuration.baseDirectory import configuration.baseDirectory

View File

@ -17,6 +17,7 @@ import org.apache.ivy.core.report.ResolveReport
import org.apache.ivy.core.resolve.ResolveOptions import org.apache.ivy.core.resolve.ResolveOptions
import org.apache.ivy.plugins.resolver.{ BasicResolver, DependencyResolver } import org.apache.ivy.plugins.resolver.{ BasicResolver, DependencyResolver }
import sbt.io.{ IO, PathFinder } import sbt.io.{ IO, PathFinder }
import sbt.internal.util.{ Logger, ShowLines, SourcePosition, LinePosition, RangePosition, LineRange }
final class DeliverConfiguration(val deliverIvyPattern: String, val status: String, val configurations: Option[Seq[Configuration]], val logging: UpdateLogging.Value) final class DeliverConfiguration(val deliverIvyPattern: String, val status: String, val configurations: Option[Seq[Configuration]], val logging: UpdateLogging.Value)
final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Seq[String], val logging: UpdateLogging.Value, final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Seq[String], val logging: UpdateLogging.Value,

View File

@ -13,6 +13,7 @@ import org.apache.ivy.plugins.repository.{ ArtifactResourceResolver, Resource, R
import org.apache.ivy.plugins.resolver.util.ResolvedResource import org.apache.ivy.plugins.resolver.util.ResolvedResource
import org.apache.ivy.util.FileUtil import org.apache.ivy.util.FileUtil
import sbt.io.Path import sbt.io.Path
import sbt.internal.util.Logger
class NotInCache(val id: ModuleID, cause: Throwable) class NotInCache(val id: ModuleID, cause: Throwable)
extends RuntimeException(NotInCache(id, cause), cause) { extends RuntimeException(NotInCache(id, cause), cause) {

View File

@ -6,6 +6,7 @@ package sbt
import java.io.File import java.io.File
import java.net.{ URI, URL } import java.net.{ URI, URL }
import scala.xml.NodeSeq import scala.xml.NodeSeq
import sbt.internal.util.Logger
final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File]) { final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File]) {
def withBase(newBaseDirectory: File) = new IvyPaths(newBaseDirectory, ivyHome) def withBase(newBaseDirectory: File) = new IvyPaths(newBaseDirectory, ivyHome)

View File

@ -4,6 +4,7 @@
package sbt package sbt
import org.apache.ivy.util.{ Message, MessageLogger, MessageLoggerEngine } import org.apache.ivy.util.{ Message, MessageLogger, MessageLoggerEngine }
import sbt.internal.util.Logger
/** Interface to Ivy logging. */ /** Interface to Ivy logging. */
private final class IvyLoggerInterface(logger: Logger) extends MessageLogger { private final class IvyLoggerInterface(logger: Logger) extends MessageLogger {

View File

@ -11,6 +11,8 @@ import org.apache.ivy.core.module.descriptor.{ DependencyDescriptor, DefaultModu
import org.apache.ivy.core.module.id.{ ArtifactId, ModuleId, ModuleRevisionId } import org.apache.ivy.core.module.id.{ ArtifactId, ModuleId, ModuleRevisionId }
import org.apache.ivy.plugins.matcher.ExactPatternMatcher import org.apache.ivy.plugins.matcher.ExactPatternMatcher
import sbt.internal.util.Logger
object ScalaArtifacts { object ScalaArtifacts {
val Organization = "org.scala-lang" val Organization = "org.scala-lang"
val LibraryID = "scala-library" val LibraryID = "scala-library"

View File

@ -6,6 +6,7 @@ import org.apache.ivy.core
import core.module.descriptor.ModuleDescriptor import core.module.descriptor.ModuleDescriptor
import sbt.serialization._ import sbt.serialization._
import java.net.{ URLEncoder, URLDecoder } import java.net.{ URLEncoder, URLDecoder }
import sbt.internal.util.Logger
private[sbt] object JsonUtil { private[sbt] object JsonUtil {
def sbtOrgTemp = "org.scala-sbt.temp" def sbtOrgTemp = "org.scala-sbt.temp"

View File

@ -8,6 +8,7 @@
package sbt package sbt
import java.io.File import java.io.File
import sbt.internal.util.Logger
import sbt.mavenint.PomExtraDependencyAttributes import sbt.mavenint.PomExtraDependencyAttributes

View File

@ -3,6 +3,7 @@ package sbt
import java.io.File import java.io.File
import org.apache.ivy.plugins.resolver.DependencyResolver import org.apache.ivy.plugins.resolver.DependencyResolver
import org.apache.ivy.core.settings.IvySettings import org.apache.ivy.core.settings.IvySettings
import sbt.internal.util.Logger
/** /**
* Represents configurable options for update task. * Represents configurable options for update task.

View File

@ -23,6 +23,7 @@ import Configurations.{ System => _, _ }
import annotation.tailrec import annotation.tailrec
import scala.concurrent.duration._ import scala.concurrent.duration._
import sbt.io.{ DirectoryFilter, Hash, IO, Path } import sbt.io.{ DirectoryFilter, Hash, IO, Path }
import sbt.internal.util.Logger
private[sbt] object CachedResolutionResolveCache { private[sbt] object CachedResolutionResolveCache {
def createID(organization: String, name: String, revision: String) = def createID(organization: String, name: String, revision: String) =

View File

@ -15,6 +15,7 @@ import org.apache.ivy.plugins.repository.url.URLResource
import org.apache.ivy.plugins.resolver._ import org.apache.ivy.plugins.resolver._
import org.apache.ivy.plugins.resolver.util.{ HasLatestStrategy, ResolvedResource } import org.apache.ivy.plugins.resolver.util.{ HasLatestStrategy, ResolvedResource }
import org.apache.ivy.util.{ Message, StringUtils => IvyStringUtils } import org.apache.ivy.util.{ Message, StringUtils => IvyStringUtils }
import sbt.internal.util.Logger
private[sbt] case class SbtChainResolver( private[sbt] case class SbtChainResolver(
name: String, name: String,

View File

@ -3,11 +3,12 @@ package sbt
import sbt.io.Path._, Configurations._ import sbt.io.Path._, Configurations._
import sbt.io.IO import sbt.io.IO
import java.io.File import java.io.File
import org.specs2._
import cross.CrossVersionUtil import cross.CrossVersionUtil
import sbt.ivyint.SbtChainResolver import sbt.ivyint.SbtChainResolver
import sbt.internal.util.{ Logger, ConsoleLogger }
import sbt.internal.util.UnitSpec
trait BaseIvySpecification extends Specification { trait BaseIvySpecification extends UnitSpec {
def currentBase: File = new File(".") def currentBase: File = new File(".")
def currentTarget: File = currentBase / "target" / "ivyhome" def currentTarget: File = currentBase / "target" / "ivyhome"
def currentManaged: File = currentBase / "target" / "lib_managed" def currentManaged: File = currentBase / "target" / "lib_managed"

View File

@ -1,33 +1,11 @@
package sbt package sbt
import org.specs2._ import sbt.internal.util.ShowLines
class CachedResolutionSpec extends BaseIvySpecification { class CachedResolutionSpec extends BaseIvySpecification {
def is = args(sequential = true) ^ s2"""
This is a specification to check the cached resolution
Resolving the same module twice should
work $e1
Resolving the unsolvable module should
not work $e2
Resolving a module with a pseudo-conflict should
work $e3
"""
def commonsIo13 = ModuleID("commons-io", "commons-io", "1.3", Some("compile"))
def mavenCayennePlugin302 = ModuleID("org.apache.cayenne.plugins", "maven-cayenne-plugin", "3.0.2", Some("compile"))
def avro177 = ModuleID("org.apache.avro", "avro", "1.7.7", Some("compile"))
def dataAvro1940 = ModuleID("com.linkedin.pegasus", "data-avro", "1.9.40", Some("compile"))
def netty320 = ModuleID("org.jboss.netty", "netty", "3.2.0.Final", Some("compile"))
def defaultOptions = EvictionWarningOptions.default
import ShowLines._ import ShowLines._
def e1 = { "Resolving the same module twice" should "work" in {
cleanIvyCache() cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")), val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
@ -38,10 +16,10 @@ class CachedResolutionSpec extends BaseIvySpecification {
println(report) println(report)
// second resolution reads from the minigraph // second resolution reads from the minigraph
println(report.configurations.head.modules.head.artifacts) println(report.configurations.head.modules.head.artifacts)
report.configurations.size must_== 3 report.configurations.size shouldBe 3
} }
def e2 = { "Resolving the unsolvable module should" should "not work" in {
// log.setLevel(Level.Debug) // log.setLevel(Level.Debug)
val m = module(ModuleID("com.example", "foo", "0.2.0", Some("compile")), val m = module(ModuleID("com.example", "foo", "0.2.0", Some("compile")),
Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
@ -53,11 +31,11 @@ class CachedResolutionSpec extends BaseIvySpecification {
ivyUpdateEither(m) match { ivyUpdateEither(m) match {
case Right(_) => sys.error("this should've failed 2") case Right(_) => sys.error("this should've failed 2")
case Left(uw) => case Left(uw) =>
uw.lines must contain(allOf("\n\tNote: Unresolved dependencies path:", uw.lines should contain allOf("\n\tNote: Unresolved dependencies path:",
"\t\tfoundrylogic.vpp:vpp:2.2.1", "\t\tfoundrylogic.vpp:vpp:2.2.1",
"\t\t +- org.apache.cayenne:cayenne-tools:3.0.2", "\t\t +- org.apache.cayenne:cayenne-tools:3.0.2",
"\t\t +- org.apache.cayenne.plugins:maven-cayenne-plugin:3.0.2", "\t\t +- org.apache.cayenne.plugins:maven-cayenne-plugin:3.0.2",
"\t\t +- com.example:foo:0.2.0")) "\t\t +- com.example:foo:0.2.0")
} }
} }
@ -65,7 +43,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
// data-avro:1.9.40 depends on avro:1.4.0, which depends on netty:3.2.1.Final. // data-avro:1.9.40 depends on avro:1.4.0, which depends on netty:3.2.1.Final.
// avro:1.4.0 will be evicted by avro:1.7.7. // avro:1.4.0 will be evicted by avro:1.7.7.
// #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final // #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final
def e3 = { "Resolving a module with a pseudo-conflict" should "work" in {
// log.setLevel(Level.Debug) // log.setLevel(Level.Debug)
cleanIvyCache() cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")), val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")),
@ -76,8 +54,16 @@ class CachedResolutionSpec extends BaseIvySpecification {
cleanCachedResolutionCache(m) cleanCachedResolutionCache(m)
// second resolution reads from the minigraph // second resolution reads from the minigraph
val report = ivyUpdate(m) val report = ivyUpdate(m)
val modules = report.configurations.head.modules val modules: Seq[String] = report.configurations.head.modules map {_.toString}
(modules must containMatch("""org\.jboss\.netty:netty:3\.2\.0.Final""")) and modules should contain("""org.jboss.netty:netty:3.2.0.Final""")
(modules must not containMatch ("""org\.jboss\.netty:netty:3\.2\.1.Final""")) modules should not contain("""org.jboss.netty:netty:3.2.1.Final""")
} }
def commonsIo13 = ModuleID("commons-io", "commons-io", "1.3", Some("compile"))
def mavenCayennePlugin302 = ModuleID("org.apache.cayenne.plugins", "maven-cayenne-plugin", "3.0.2", Some("compile"))
def avro177 = ModuleID("org.apache.avro", "avro", "1.7.7", Some("compile"))
def dataAvro1940 = ModuleID("com.linkedin.pegasus", "data-avro", "1.9.40", Some("compile"))
def netty320 = ModuleID("org.jboss.netty", "netty", "3.2.0.Final", Some("compile"))
def defaultOptions = EvictionWarningOptions.default
} }

View File

@ -2,73 +2,74 @@ package sbt
import java.io.File import java.io.File
import java.util.concurrent.Callable import java.util.concurrent.Callable
import org.specs2._
import mutable.Specification
import sbt.io.IO.{ createDirectory, delete, touch, withTemporaryDirectory } import sbt.io.IO.{ createDirectory, delete, touch, withTemporaryDirectory }
import sbt.io.IO import sbt.io.IO
import org.apache.ivy.util.ChecksumHelper import org.apache.ivy.util.ChecksumHelper
import IfMissing.Fail import IfMissing.Fail
import xsbti.ComponentProvider import xsbti.ComponentProvider
import sbt.internal.util.Logger
import sbt.internal.util.{ UnitSpec, TestLogger }
// TODO - We need to re-enable this test. Right now, we dont' have a "stub" launcher for this. // TODO - We need to re-enable this test. Right now, we dont' have a "stub" launcher for this.
// This is testing something which uses a launcher interface, but was grabbing the underlying class directly // This is testing something which uses a launcher interface, but was grabbing the underlying class directly
// when it really should, instead, be stubbing out the underyling class. // when it really should, instead, be stubbing out the underyling class.
object ComponentManagerTest extends Specification { class ComponentManagerTest extends UnitSpec {
val TestID = "manager-test" val TestID = "manager-test"
"Component manager" should { "Component manager" should "throw an exception if 'file' is called for a non-existing component" in {
"throw an exception if 'file' is called for a non-existing component" in { withManager { manager =>
withManager { _.file(TestID)(Fail) must throwA[InvalidComponent] } intercept[InvalidComponent] { manager.file(TestID)(Fail) }
} }
"throw an exception if 'file' is called for an empty component" in { }
withManager { manager => it should "throw an exception if 'file' is called for an empty component" in {
manager.define(TestID, Nil) withManager { manager =>
(manager.file(TestID)(Fail)) must throwA[InvalidComponent] manager.define(TestID, Nil)
} intercept[InvalidComponent] { manager.file(TestID)(Fail) }
} }
"return the file for a single-file component" in { }
withManager { manager => it should "return the file for a single-file component" in {
val hash = defineFile(manager, TestID, "a") withManager { manager =>
checksum(manager.file(TestID)(Fail)) must beEqualTo(hash) val hash = defineFile(manager, TestID, "a")
} checksum(manager.file(TestID)(Fail)) shouldBe hash
} }
}
"throw an exception if 'file' is called for multi-file component" in { it should "throw an exception if 'file' is called for multi-file component" in {
withManager { manager => withManager { manager =>
defineFiles(manager, TestID, "a", "b") defineFiles(manager, TestID, "a", "b")
(manager.file(TestID)(Fail)) must throwA[InvalidComponent] intercept[InvalidComponent] { manager.file(TestID)(Fail) }
}
} }
"return the files for a multi-file component" in { }
withManager { manager => it should "return the files for a multi-file component" in {
val hashes = defineFiles(manager, TestID, "a", "b") withManager { manager =>
checksum(manager.files(TestID)(Fail)) must containTheSameElementsAs(hashes) val hashes = defineFiles(manager, TestID, "a", "b")
} checksum(manager.files(TestID)(Fail)) should contain theSameElementsAs (hashes)
} }
"return the files for a single-file component" in { }
withManager { manager => it should "return the files for a single-file component" in {
val hashes = defineFiles(manager, TestID, "a") withManager { manager =>
checksum(manager.files(TestID)(Fail)) must containTheSameElementsAs(hashes) val hashes = defineFiles(manager, TestID, "a")
} checksum(manager.files(TestID)(Fail)) should contain theSameElementsAs (hashes)
} }
"throw an exception if 'files' is called for a non-existing component" in { }
withManager { _.files(TestID)(Fail) must throwA[InvalidComponent] } it should "throw an exception if 'files' is called for a non-existing component" in {
withManager { manager =>
intercept[InvalidComponent] { manager.files(TestID)(Fail) }
} }
}
"properly cache a file and then retrieve it to an unresolved component" in { it should "properly cache a file and then retrieve it to an unresolved component" in {
withTemporaryDirectory { ivyHome => withTemporaryDirectory { ivyHome =>
withManagerHome(ivyHome) { definingManager => withManagerHome(ivyHome) { definingManager =>
val hash = defineFile(definingManager, TestID, "a") val hash = defineFile(definingManager, TestID, "a")
try { try {
definingManager.cache(TestID) definingManager.cache(TestID)
withManagerHome(ivyHome) { usingManager => withManagerHome(ivyHome) { usingManager =>
checksum(usingManager.file(TestID)(Fail)) must beEqualTo(hash) checksum(usingManager.file(TestID)(Fail)) shouldBe hash
} }
} finally { definingManager.clearCache(TestID) } } finally { definingManager.clearCache(TestID) }
}
} }
} }
} }
private def checksum(files: Iterable[File]): Seq[String] = files.map(checksum).toSeq private def checksum(files: Iterable[File]): Seq[String] = files.map(checksum).toSeq
private def checksum(file: File): String = if (file.exists) ChecksumHelper.computeAsString(file, "sha1") else "" private def checksum(file: File): String = if (file.exists) ChecksumHelper.computeAsString(file, "sha1") else ""
private def defineFile(manager: ComponentManager, id: String, name: String): String = createFile(manager, id, name)(checksum) private def defineFile(manager: ComponentManager, id: String, name: String): String = createFile(manager, id, name)(checksum)

View File

@ -1,122 +1,118 @@
package sbt package sbt
import java.io.File import java.io.File
import org.specs2._ import sbt.internal.util.UnitSpec
import mutable.Specification
object CrossVersionTest extends Specification { class CrossVersionTest extends UnitSpec {
"Cross version" should { "Cross version" should "return sbt API for xyz as None" in {
"return sbt API for xyz as None" in { CrossVersion.sbtApiVersion("xyz") shouldBe None
CrossVersion.sbtApiVersion("xyz") must_== None }
} it should "return sbt API for 0.12 as None" in {
"return sbt API for 0.12 as None" in { CrossVersion.sbtApiVersion("0.12") shouldBe None
CrossVersion.sbtApiVersion("0.12") must_== None }
} it should "return sbt API for 0.12.0-SNAPSHOT as None" in {
"return sbt API for 0.12.0-SNAPSHOT as None" in { CrossVersion.sbtApiVersion("0.12.0-SNAPSHOT") shouldBe None
CrossVersion.sbtApiVersion("0.12.0-SNAPSHOT") must_== None }
} it should "return sbt API for 0.12.0-RC1 as Some((0, 12))" in {
"return sbt API for 0.12.0-RC1 as Some((0, 12))" in { CrossVersion.sbtApiVersion("0.12.0-RC1") shouldBe Some((0, 12))
CrossVersion.sbtApiVersion("0.12.0-RC1") must_== Some((0, 12)) }
} it should "return sbt API for 0.12.0 as Some((0, 12))" in {
"return sbt API for 0.12.0 as Some((0, 12))" in { CrossVersion.sbtApiVersion("0.12.0") shouldBe Some((0, 12))
CrossVersion.sbtApiVersion("0.12.0") must_== Some((0, 12)) }
} it should "return sbt API for 0.12.1-SNAPSHOT as Some((0, 12))" in {
"return sbt API for 0.12.1-SNAPSHOT as Some((0, 12))" in { CrossVersion.sbtApiVersion("0.12.1-SNAPSHOT") shouldBe Some((0, 12))
CrossVersion.sbtApiVersion("0.12.1-SNAPSHOT") must_== Some((0, 12)) }
} it should "return sbt API for 0.12.1-RC1 as Some((0, 12))" in {
"return sbt API for 0.12.1-RC1 as Some((0, 12))" in { CrossVersion.sbtApiVersion("0.12.1-RC1") shouldBe Some((0, 12))
CrossVersion.sbtApiVersion("0.12.1-RC1") must_== Some((0, 12)) }
} it should "return sbt API for 0.12.1 as Some((0, 12))" in {
"return sbt API for 0.12.1 as Some((0, 12))" in { CrossVersion.sbtApiVersion("0.12.1") shouldBe Some((0, 12))
CrossVersion.sbtApiVersion("0.12.1") must_== Some((0, 12)) }
} it should "return sbt API compatibility for 0.12.0-M1 as false" in {
"return sbt API compatibility for 0.12.0-M1 as false" in { CrossVersion.isSbtApiCompatible("0.12.0-M1") shouldBe false
CrossVersion.isSbtApiCompatible("0.12.0-M1") must_== false }
} it should "return sbt API compatibility for 0.12.0-RC1 as true" in {
"return sbt API compatibility for 0.12.0-RC1 as true" in { CrossVersion.isSbtApiCompatible("0.12.0-RC1") shouldBe true
CrossVersion.isSbtApiCompatible("0.12.0-RC1") must_== true }
} it should "return sbt API compatibility for 0.12.1-RC1 as true" in {
"return sbt API compatibility for 0.12.1-RC1 as true" in { CrossVersion.isSbtApiCompatible("0.12.1-RC1") shouldBe true
CrossVersion.isSbtApiCompatible("0.12.1-RC1") must_== true }
} it should "return binary sbt version for 0.11.3 as 0.11.3" in {
"return binary sbt version for 0.11.3 as 0.11.3" in { CrossVersion.binarySbtVersion("0.11.3") shouldBe "0.11.3"
CrossVersion.binarySbtVersion("0.11.3") must_== "0.11.3" }
} it should "return binary sbt version for 0.12.0-M1 as 0.12.0-M1" in {
"return binary sbt version for 0.12.0-M1 as 0.12.0-M1" in { CrossVersion.binarySbtVersion("0.12.0-M1") shouldBe "0.12.0-M1"
CrossVersion.binarySbtVersion("0.12.0-M1") must_== "0.12.0-M1" }
} it should "return binary sbt version for 0.12.0-RC1 as 0.12" in {
"return binary sbt version for 0.12.0-RC1 as 0.12" in { CrossVersion.binarySbtVersion("0.12.0-RC1") shouldBe "0.12"
CrossVersion.binarySbtVersion("0.12.0-RC1") must_== "0.12" }
} it should "return binary sbt version for 0.12.0 as 0.12" in {
"return binary sbt version for 0.12.0 as 0.12" in { CrossVersion.binarySbtVersion("0.12.0") shouldBe "0.12"
CrossVersion.binarySbtVersion("0.12.0") must_== "0.12" }
} it should "return binary sbt version for 0.12.1-SNAPSHOT as 0.12" in {
"return binary sbt version for 0.12.1-SNAPSHOT as 0.12" in { CrossVersion.binarySbtVersion("0.12.1-SNAPSHOT") shouldBe "0.12"
CrossVersion.binarySbtVersion("0.12.1-SNAPSHOT") must_== "0.12" }
} it should "return binary sbt version for 0.12.1-RC1 as 0.12" in {
"return binary sbt version for 0.12.1-RC1 as 0.12" in { CrossVersion.binarySbtVersion("0.12.1-RC1") shouldBe "0.12"
CrossVersion.binarySbtVersion("0.12.1-RC1") must_== "0.12" }
} it should "return binary sbt version for 0.12.1 as 0.12" in {
"return binary sbt version for 0.12.1 as 0.12" in { CrossVersion.binarySbtVersion("0.12.1") shouldBe "0.12"
CrossVersion.binarySbtVersion("0.12.1") must_== "0.12" }
} it should "return Scala API for xyz as None" in {
CrossVersion.scalaApiVersion("xyz") shouldBe None
"return Scala API for xyz as None" in { }
CrossVersion.scalaApiVersion("xyz") must_== None it should "return Scala API for 2.10 as None" in {
} CrossVersion.scalaApiVersion("2.10") shouldBe None
"return Scala API for 2.10 as None" in { }
CrossVersion.scalaApiVersion("2.10") must_== None it should "return Scala API for 2.10.0-SNAPSHOT as None" in {
} CrossVersion.scalaApiVersion("2.10.0-SNAPSHOT") shouldBe None
"return Scala API for 2.10.0-SNAPSHOT as None" in { }
CrossVersion.scalaApiVersion("2.10.0-SNAPSHOT") must_== None it should "return Scala API for 2.10.0-RC1 as None" in {
} CrossVersion.scalaApiVersion("2.10.0-RC1") shouldBe None
"return Scala API for 2.10.0-RC1 as None" in { }
CrossVersion.scalaApiVersion("2.10.0-RC1") must_== None it should "return Scala API for 2.10.0 as Some((2, 10))" in {
} CrossVersion.scalaApiVersion("2.10.0") shouldBe Some((2, 10))
"return Scala API for 2.10.0 as Some((2, 10))" in { }
CrossVersion.scalaApiVersion("2.10.0") must_== Some((2, 10)) it should "return Scala API for 2.10.0-1 as Some((2, 10))" in {
} CrossVersion.scalaApiVersion("2.10.0-1") shouldBe Some((2, 10))
"return Scala API for 2.10.0-1 as Some((2, 10))" in { }
CrossVersion.scalaApiVersion("2.10.0-1") must_== Some((2, 10)) it should "return Scala API for 2.10.1-SNAPSHOT as Some((2, 10))" in {
} CrossVersion.scalaApiVersion("2.10.1-SNAPSHOT") shouldBe Some((2, 10))
"return Scala API for 2.10.1-SNAPSHOT as Some((2, 10))" in { }
CrossVersion.scalaApiVersion("2.10.1-SNAPSHOT") must_== Some((2, 10)) it should "return Scala API for 2.10.1-RC1 as Some((2, 10))" in {
} CrossVersion.scalaApiVersion("2.10.1-RC1") shouldBe Some((2, 10))
"return Scala API for 2.10.1-RC1 as Some((2, 10))" in { }
CrossVersion.scalaApiVersion("2.10.1-RC1") must_== Some((2, 10)) it should "return Scala API for 2.10.1 as Some((2, 10))" in {
} CrossVersion.scalaApiVersion("2.10.1") shouldBe Some((2, 10))
"return Scala API for 2.10.1 as Some((2, 10))" in { }
CrossVersion.scalaApiVersion("2.10.1") must_== Some((2, 10)) it should "return Scala API compatibility for 2.10.0-M1 as false" in {
} CrossVersion.isScalaApiCompatible("2.10.0-M1") shouldBe false
"return Scala API compatibility for 2.10.0-M1 as false" in { }
CrossVersion.isScalaApiCompatible("2.10.0-M1") must_== false it should "return Scala API compatibility for 2.10.0-RC1 as false" in {
} CrossVersion.isScalaApiCompatible("2.10.0-RC1") shouldBe false
"return Scala API compatibility for 2.10.0-RC1 as false" in { }
CrossVersion.isScalaApiCompatible("2.10.0-RC1") must_== false it should "return Scala API compatibility for 2.10.1-RC1 as false" in {
} CrossVersion.isScalaApiCompatible("2.10.1-RC1") shouldBe true
"return Scala API compatibility for 2.10.1-RC1 as false" in { }
CrossVersion.isScalaApiCompatible("2.10.1-RC1") must_== true it should "return binary Scala version for 2.9.2 as 2.9.2" in {
} CrossVersion.binaryScalaVersion("2.9.2") shouldBe "2.9.2"
"return binary Scala version for 2.9.2 as 2.9.2" in { }
CrossVersion.binaryScalaVersion("2.9.2") must_== "2.9.2" it should "return binary Scala version for 2.10.0-M1 as 2.10.0-M1" in {
} CrossVersion.binaryScalaVersion("2.10.0-M1") shouldBe "2.10.0-M1"
"return binary Scala version for 2.10.0-M1 as 2.10.0-M1" in { }
CrossVersion.binaryScalaVersion("2.10.0-M1") must_== "2.10.0-M1" it should "return binary Scala version for 2.10.0-RC1 as 2.10.0-RC1" in {
} CrossVersion.binaryScalaVersion("2.10.0-RC1") shouldBe "2.10.0-RC1"
"return binary Scala version for 2.10.0-RC1 as 2.10.0-RC1" in { }
CrossVersion.binaryScalaVersion("2.10.0-RC1") must_== "2.10.0-RC1" it should "return binary Scala version for 2.10.0 as 2.10" in {
} CrossVersion.binaryScalaVersion("2.10.0") shouldBe "2.10"
"return binary Scala version for 2.10.0 as 2.10" in { }
CrossVersion.binaryScalaVersion("2.10.0") must_== "2.10" it should "return binary Scala version for 2.10.1-M1 as 2.10" in {
} CrossVersion.binaryScalaVersion("2.10.1-M1") shouldBe "2.10"
"return binary Scala version for 2.10.1-M1 as 2.10" in { }
CrossVersion.binaryScalaVersion("2.10.1-M1") must_== "2.10" it should "return binary Scala version for 2.10.1-RC1 as 2.10" in {
} CrossVersion.binaryScalaVersion("2.10.1-RC1") shouldBe "2.10"
"return binary Scala version for 2.10.1-RC1 as 2.10" in { }
CrossVersion.binaryScalaVersion("2.10.1-RC1") must_== "2.10" it should "return binary Scala version for 2.10.1 as 2.10" in {
} CrossVersion.binaryScalaVersion("2.10.1") shouldBe "2.10"
"return binary Scala version for 2.10.1 as 2.10" in {
CrossVersion.binaryScalaVersion("2.10.1") must_== "2.10"
}
} }
} }

View File

@ -2,36 +2,32 @@ import java.io.File
import org.apache.ivy.core.module.descriptor.{ Artifact => IvyArtifact } import org.apache.ivy.core.module.descriptor.{ Artifact => IvyArtifact }
import org.apache.ivy.core.module.id.ModuleRevisionId import org.apache.ivy.core.module.id.ModuleRevisionId
import org.apache.ivy.core.resolve.ResolveOptions import org.apache.ivy.core.resolve.ResolveOptions
import org.specs2.mutable.Specification
import sbt._ import sbt._
import sbt.io.IO.withTemporaryDirectory import sbt.io.IO.withTemporaryDirectory
import sbt.internal.util.{ Logger, ConsoleLogger }
import sbt.internal.util.UnitSpec
object CustomPomParserTest extends Specification { class CustomPomParserTest extends UnitSpec {
"CustomPomParser" should "resolve an artifact with packaging 'scala-jar' as a regular jar file." in {
val log = ConsoleLogger()
withTemporaryDirectory { cacheDir =>
val repoUrl = getClass.getResource("/test-maven-repo")
val local = MavenRepository("Test Repo", repoUrl.toExternalForm)
val paths = new IvyPaths(new File("."), Some(cacheDir))
val conf = new InlineIvyConfiguration(paths, Seq(local), Nil, Nil, false, None, Seq("sha1", "md5"), None, log)
val ivySbt = new IvySbt(conf)
val resolveOpts = new ResolveOptions().setConfs(Array("default"))
val mrid = ModuleRevisionId.newInstance("com.test", "test-artifact", "1.0.0-SNAPSHOT")
"CustomPomParser" should { val resolveReport = ivySbt.withIvy(log) { ivy =>
"resolve an artifact with packaging 'scala-jar' as a regular jar file." in { ivy.resolve(mrid, resolveOpts, true)
val log = ConsoleLogger()
withTemporaryDirectory { cacheDir =>
val repoUrl = getClass.getResource("/test-maven-repo")
val local = MavenRepository("Test Repo", repoUrl.toExternalForm)
val paths = new IvyPaths(new File("."), Some(cacheDir))
val conf = new InlineIvyConfiguration(paths, Seq(local), Nil, Nil, false, None, Seq("sha1", "md5"), None, log)
val ivySbt = new IvySbt(conf)
val resolveOpts = new ResolveOptions().setConfs(Array("default"))
val mrid = ModuleRevisionId.newInstance("com.test", "test-artifact", "1.0.0-SNAPSHOT")
val resolveReport = ivySbt.withIvy(log) { ivy =>
ivy.resolve(mrid, resolveOpts, true)
}
resolveReport.hasError must beFalse
resolveReport.getArtifacts.size() must beEqualTo(1)
val artifact: IvyArtifact = resolveReport.getArtifacts.asInstanceOf[java.util.List[IvyArtifact]].get(0)
artifact.getModuleRevisionId must beEqualTo(mrid)
artifact.getExt must beEqualTo("jar")
} }
resolveReport.hasError shouldBe false
resolveReport.getArtifacts.size() shouldBe 1
val artifact: IvyArtifact = resolveReport.getArtifacts.asInstanceOf[java.util.List[IvyArtifact]].get(0)
artifact.getModuleRevisionId shouldBe mrid
artifact.getExt shouldBe "jar"
} }
} }
} }

View File

@ -1,46 +1,50 @@
package sbt package sbt
import org.specs2._
import matcher.MatchResult
import java.net.URL import java.net.URL
import java.io.File import java.io.File
import sbt.serialization._ import sbt.serialization._
import sbt.internal.util.UnitSpec
class DMSerializationSpec extends Specification { class DMSerializationSpec extends UnitSpec {
def is = sequential ^ s2""" "CrossVersion.full" should "roundtrip" in {
roundtripStr(CrossVersion.full: sbt.CrossVersion)
This is a specification to check the serialization of dependency graph. }
"CrossVersion.binary" should "roundtrip" in {
CrossVersion.full should roundtripStr(CrossVersion.binary: sbt.CrossVersion)
${roundtripStr(CrossVersion.full: sbt.CrossVersion)} }
CrossVersion.binary should "CrossVersion.Disabled" should "roundtrip" in {
${roundtripStr(CrossVersion.binary: sbt.CrossVersion)} roundtrip(CrossVersion.Disabled: sbt.CrossVersion)
CrossVersion.Disabled should }
${roundtrip(CrossVersion.Disabled: sbt.CrossVersion)} """Artifact("foo")""" should "roundtrip" in {
roundtrip(Artifact("foo"))
Artifact("foo") should }
${roundtrip(Artifact("foo"))} """Artifact("foo", "sources")""" should "roundtrip" in {
Artifact("foo", "sources") should roundtrip(Artifact("foo", "sources"))
${roundtrip(Artifact("foo", "sources"))} }
Artifact.pom("foo") should """Artifact.pom("foo")""" should "roundtrip" in {
${roundtrip(Artifact.pom("foo"))} roundtrip(Artifact.pom("foo"))
Artifact("foo", url("http://example.com/")) should }
${roundtrip(Artifact("foo", new URL("http://example.com/")))} """Artifact("foo", url("http://example.com/"))""" should "roundtrip" in {
Artifact("foo").extra(("key", "value")) should roundtrip(Artifact("foo", new URL("http://example.com/")))
${roundtrip(Artifact("foo").extra(("key", "value")))} }
"""Artifact("foo").extra(("key", "value"))""" should "roundtrip" in {
ModuleID("org", "name", "1.0") should roundtrip(Artifact("foo").extra(("key", "value")))
${roundtrip(ModuleID("org", "name", "1.0"))} }
"""ModuleID("org", "name", "1.0")""" should "roundtrip" in {
ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil) should roundtrip(ModuleID("org", "name", "1.0"))
${roundtripStr(ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil))} }
Organization artifact report should """ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil)""" should "roundtrip" in {
${roundtripStr(organizationArtifactReportExample)} roundtripStr(ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil))
Configuration report should }
${roundtripStr(configurationReportExample)} "Organization artifact report" should "roundtrip" in {
Update report should roundtripStr(organizationArtifactReportExample)
${roundtripStr(updateReportExample)} }
""" "Configuration report" should "roundtrip" in {
roundtripStr(configurationReportExample)
}
"Update report" should "roundtrip" in {
roundtripStr(updateReportExample)
}
lazy val updateReportExample = lazy val updateReportExample =
new UpdateReport(new File("./foo"), Vector(configurationReportExample), new UpdateReport(new File("./foo"), Vector(configurationReportExample),
@ -53,11 +57,11 @@ class DMSerializationSpec extends Specification {
lazy val moduleReportExample = lazy val moduleReportExample =
ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil) ModuleReport(ModuleID("org", "name", "1.0"), Nil, Nil)
def roundtrip[A: Pickler: Unpickler](a: A) = def roundtrip[A: Pickler: Unpickler](a: A): Unit =
roundtripBuilder(a) { _ must_== _ } roundtripBuilder(a) { _ shouldBe _ }
def roundtripStr[A: Pickler: Unpickler](a: A) = def roundtripStr[A: Pickler: Unpickler](a: A): Unit =
roundtripBuilder(a) { _.toString must_== _.toString } roundtripBuilder(a) { _.toString shouldBe _.toString }
def roundtripBuilder[A: Pickler: Unpickler](a: A)(f: (A, A) => MatchResult[Any]): MatchResult[Any] = def roundtripBuilder[A: Pickler: Unpickler](a: A)(f: (A, A) => Unit): Unit =
{ {
val json = toJsonString(a) val json = toJsonString(a)
println(json) println(json)

View File

@ -1,52 +1,40 @@
package sbt package sbt
import org.specs2._
class EvictionWarningSpec extends BaseIvySpecification { class EvictionWarningSpec extends BaseIvySpecification {
def is = s2""" // This is a specification to check the eviction warnings
This is a specification to check the eviction warnings "Eviction of scala-library whose scalaVersion" should "be detected" in scalaVersionWarn1
it should "not be detected if it's diabled" in scalaVersionWarn2
it should "print out message about the eviction" in scalaVersionWarn3
it should "print out message about the eviction with callers" in scalaVersionWarn4
Eviction of scala-library whose scalaVersion should """Including two (suspect) binary incompatible Java libraries to
be detected $scalaVersionWarn1 direct dependencies""" should "be detected as eviction" in javaLibWarn1
not be detected if it's diabled $scalaVersionWarn2 it should "not be detected if it's disabled" in javaLibWarn2
print out message about the eviction $scalaVersionWarn3 it should "print out message about the eviction" in javaLibWarn3
print out message about the eviction with callers $scalaVersionWarn4 it should "print out message about the eviction with callers" in javaLibWarn4
Including two (suspect) binary incompatible Java libraries to """Including two (suspect) binary compatible Java libraries to
direct dependencies should direct dependencies""" should "not be detected as eviction" in javaLibNoWarn1
be detected as eviction $javaLibWarn1 it should "print out message about the eviction" in javaLibNoWarn2
not be detected if it's disabled $javaLibWarn2
print out message about the eviction $javaLibWarn3
print out message about the eviction with callers $javaLibWarn4
Including two (suspect) binary compatible Java libraries to """Including two (suspect) transitively binary incompatible Java libraries to
direct dependencies should direct dependencies""" should "be not detected as eviction" in javaLibTransitiveWarn1
not be detected as eviction $javaLibNoWarn1 it should "be detected if it's enabled" in javaLibTransitiveWarn2
print out message about the eviction $javaLibNoWarn2 it should "print out message about the eviction if it's enabled" in javaLibTransitiveWarn3
Including two (suspect) transitively binary incompatible Java libraries to """Including two (suspect) binary incompatible Scala libraries to
direct dependencies should direct dependencies""" should "be detected as eviction" in scalaLibWarn1
be not detected as eviction $javaLibTransitiveWarn1 it should "print out message about the eviction" in scalaLibWarn2
be detected if it's enabled $javaLibTransitiveWarn2
print out message about the eviction if it's enabled $javaLibTransitiveWarn3
Including two (suspect) binary incompatible Scala libraries to """Including two (suspect) binary compatible Scala libraries to
direct dependencies should direct dependencies""" should "not be detected as eviction" in scalaLibNoWarn1
be detected as eviction $scalaLibWarn1 it should "print out message about the eviction" in scalaLibNoWarn2
print out message about the eviction $scalaLibWarn2
Including two (suspect) binary compatible Scala libraries to """Including two (suspect) transitively binary incompatible Scala libraries to
direct dependencies should direct dependencies""" should "be not detected as eviction" in scalaLibTransitiveWarn1
not be detected as eviction $scalaLibNoWarn1 it should "be detected if it's enabled" in scalaLibTransitiveWarn2
print out message about the eviction $scalaLibNoWarn2 it should "print out message about the eviction if it's enabled" in scalaLibTransitiveWarn3
Including two (suspect) transitively binary incompatible Scala libraries to
direct dependencies should
be not detected as eviction $scalaLibTransitiveWarn1
be detected if it's enabled $scalaLibTransitiveWarn2
print out message about the eviction if it's enabled $scalaLibTransitiveWarn3
"""
def akkaActor214 = ModuleID("com.typesafe.akka", "akka-actor", "2.1.4", Some("compile")) cross CrossVersion.binary def akkaActor214 = ModuleID("com.typesafe.akka", "akka-actor", "2.1.4", Some("compile")) cross CrossVersion.binary
def akkaActor230 = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("compile")) cross CrossVersion.binary def akkaActor230 = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("compile")) cross CrossVersion.binary
@ -64,26 +52,26 @@ class EvictionWarningSpec extends BaseIvySpecification {
def defaultOptions = EvictionWarningOptions.default def defaultOptions = EvictionWarningOptions.default
import ShowLines._ import sbt.internal.util.ShowLines._
def scalaVersionDeps = Seq(scala2102, akkaActor230) def scalaVersionDeps = Seq(scala2102, akkaActor230)
def scalaVersionWarn1 = { def scalaVersionWarn1 = {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2")) val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).scalaEvictions must have size (1) EvictionWarning(m, defaultOptions, report, log).scalaEvictions should have size(1)
} }
def scalaVersionWarn2 = { def scalaVersionWarn2 = {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2")) val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnScalaVersionEviction(false), report, log).scalaEvictions must have size (0) EvictionWarning(m, defaultOptions.withWarnScalaVersionEviction(false), report, log).scalaEvictions should have size(0)
} }
def scalaVersionWarn3 = { def scalaVersionWarn3 = {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2")) val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines must_== EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("Scala version was updated by one of library dependencies:", List("Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3", "\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3",
"To force scalaVersion, add the following:", "To force scalaVersion, add the following:",
@ -94,7 +82,7 @@ class EvictionWarningSpec extends BaseIvySpecification {
def scalaVersionWarn4 = { def scalaVersionWarn4 = {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2")) val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines must_== EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines shouldBe
List("Scala version was updated by one of library dependencies:", List("Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3 (caller: com.typesafe.akka:akka-actor_2.10:2.3.0, com.example:foo:0.1.0)", "\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3 (caller: com.typesafe.akka:akka-actor_2.10:2.3.0, com.example:foo:0.1.0)",
"To force scalaVersion, add the following:", "To force scalaVersion, add the following:",
@ -106,19 +94,19 @@ class EvictionWarningSpec extends BaseIvySpecification {
def javaLibWarn1 = { def javaLibWarn1 = {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (1) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(1)
} }
def javaLibWarn2 = { def javaLibWarn2 = {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnDirectEvictions(false), report, log).reportedEvictions must have size (0) EvictionWarning(m, defaultOptions.withWarnDirectEvictions(false), report, log).reportedEvictions should have size(0)
} }
def javaLibWarn3 = { def javaLibWarn3 = {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines must_== EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.", List("There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:", "Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4", "\t* commons-io:commons-io:1.4 -> 2.4",
@ -128,7 +116,7 @@ class EvictionWarningSpec extends BaseIvySpecification {
def javaLibWarn4 = { def javaLibWarn4 = {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines must_== EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.", List("There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:", "Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: com.example:foo:0.1.0)") "\t* commons-io:commons-io:1.4 -> 2.4 (caller: com.example:foo:0.1.0)")
@ -138,14 +126,14 @@ class EvictionWarningSpec extends BaseIvySpecification {
val deps = Seq(commonsIo14, commonsIo13) val deps = Seq(commonsIo14, commonsIo13)
val m = module(defaultModuleId, deps, Some("2.10.3")) val m = module(defaultModuleId, deps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (0) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(0)
} }
def javaLibNoWarn2 = { def javaLibNoWarn2 = {
val deps = Seq(commonsIo14, commonsIo13) val deps = Seq(commonsIo14, commonsIo13)
val m = module(defaultModuleId, deps, Some("2.10.3")) val m = module(defaultModuleId, deps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines must_== Nil EvictionWarning(m, defaultOptions, report, log).lines shouldBe Nil
} }
def javaLibTransitiveDeps = Seq(unfilteredUploads080, bnfparser10) def javaLibTransitiveDeps = Seq(unfilteredUploads080, bnfparser10)
@ -153,19 +141,19 @@ class EvictionWarningSpec extends BaseIvySpecification {
def javaLibTransitiveWarn1 = { def javaLibTransitiveWarn1 = {
val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (0) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(0)
} }
def javaLibTransitiveWarn2 = { def javaLibTransitiveWarn2 = {
val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true), report, log).reportedEvictions must have size (1) EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true), report, log).reportedEvictions should have size(1)
} }
def javaLibTransitiveWarn3 = { def javaLibTransitiveWarn3 = {
val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3")) val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines must_== EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.", List("There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:", "Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: ca.gobits.bnf:bnfparser:1.0, net.databinder:unfiltered-uploads_2.10:0.8.0)") "\t* commons-io:commons-io:1.4 -> 2.4 (caller: ca.gobits.bnf:bnfparser:1.0, net.databinder:unfiltered-uploads_2.10:0.8.0)")
@ -175,14 +163,14 @@ class EvictionWarningSpec extends BaseIvySpecification {
val deps = Seq(scala2104, akkaActor214, akkaActor234) val deps = Seq(scala2104, akkaActor214, akkaActor234)
val m = module(defaultModuleId, deps, Some("2.10.4")) val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (1) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(1)
} }
def scalaLibWarn2 = { def scalaLibWarn2 = {
val deps = Seq(scala2104, akkaActor214, akkaActor234) val deps = Seq(scala2104, akkaActor214, akkaActor234)
val m = module(defaultModuleId, deps, Some("2.10.4")) val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines must_== EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.", List("There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:", "Here are some of the libraries that were evicted:",
"\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4", "\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4",
@ -193,14 +181,14 @@ class EvictionWarningSpec extends BaseIvySpecification {
val deps = Seq(scala2104, akkaActor230, akkaActor234) val deps = Seq(scala2104, akkaActor230, akkaActor234)
val m = module(defaultModuleId, deps, Some("2.10.4")) val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (0) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(0)
} }
def scalaLibNoWarn2 = { def scalaLibNoWarn2 = {
val deps = Seq(scala2104, akkaActor230, akkaActor234) val deps = Seq(scala2104, akkaActor230, akkaActor234)
val m = module(defaultModuleId, deps, Some("2.10.4")) val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines must_== Nil EvictionWarning(m, defaultOptions, report, log).lines shouldBe Nil
} }
def scalaLibTransitiveDeps = Seq(scala2104, bananaSesame04, akkaRemote234) def scalaLibTransitiveDeps = Seq(scala2104, bananaSesame04, akkaRemote234)
@ -208,19 +196,19 @@ class EvictionWarningSpec extends BaseIvySpecification {
def scalaLibTransitiveWarn1 = { def scalaLibTransitiveWarn1 = {
val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4")) val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).reportedEvictions must have size (0) EvictionWarning(m, defaultOptions, report, log).reportedEvictions should have size(0)
} }
def scalaLibTransitiveWarn2 = { def scalaLibTransitiveWarn2 = {
val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4")) val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true), report, log).reportedEvictions must have size (1) EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true), report, log).reportedEvictions should have size(1)
} }
def scalaLibTransitiveWarn3 = { def scalaLibTransitiveWarn3 = {
val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4")) val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4"))
val report = ivyUpdate(m) val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines must_== EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.", List("There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:", "Here are some of the libraries that were evicted:",
"\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4 (caller: com.typesafe.akka:akka-remote_2.10:2.3.4, org.w3:banana-sesame_2.10:0.4, org.w3:banana-rdf_2.10:0.4)") "\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4 (caller: com.typesafe.akka:akka-remote_2.10:2.3.4, org.w3:banana-sesame_2.10:0.4, org.w3:banana-rdf_2.10:0.4)")

View File

@ -1,28 +1,20 @@
package sbt package sbt
import org.specs2._ import sbt.internal.util.UnitSpec
class InconsistentDuplicateSpec extends Specification { // This is a specification to check the inconsistent duplicate warnings
def is = s2""" class InconsistentDuplicateSpec extends UnitSpec {
"Duplicate with different version" should "be warned" in {
IvySbt.inconsistentDuplicateWarning(Seq(akkaActor214, akkaActor230)) shouldBe
List("Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:",
" * com.typesafe.akka:akka-actor:(2.1.4, 2.3.0)")
}
This is a specification to check the inconsistent duplicate warnings "Duplicate with same version" should "not be warned" in {
IvySbt.inconsistentDuplicateWarning(Seq(akkaActor230Test, akkaActor230)) shouldBe Nil
Duplicate with different version should }
be warned $warn1
Duplicate with same version should
not be warned $nodupe1
"""
def akkaActor214 = ModuleID("com.typesafe.akka", "akka-actor", "2.1.4", Some("compile")) cross CrossVersion.binary def akkaActor214 = ModuleID("com.typesafe.akka", "akka-actor", "2.1.4", Some("compile")) cross CrossVersion.binary
def akkaActor230 = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("compile")) cross CrossVersion.binary def akkaActor230 = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("compile")) cross CrossVersion.binary
def akkaActor230Test = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("test")) cross CrossVersion.binary def akkaActor230Test = ModuleID("com.typesafe.akka", "akka-actor", "2.3.0", Some("test")) cross CrossVersion.binary
def warn1 =
IvySbt.inconsistentDuplicateWarning(Seq(akkaActor214, akkaActor230)) must_==
List("Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:",
" * com.typesafe.akka:akka-actor:(2.1.4, 2.3.0)")
def nodupe1 =
IvySbt.inconsistentDuplicateWarning(Seq(akkaActor230Test, akkaActor230)) must_== Nil
} }

View File

@ -1,73 +1,78 @@
package sbt package sbt
import java.io.File import java.io.File
import org.specs2._ import sbt.internal.util.{ Logger, ConsoleLogger }
import sbt.internal.util.UnitSpec
// http://ant.apache.org/ivy/history/2.3.0/ivyfile/dependency.html // http://ant.apache.org/ivy/history/2.3.0/ivyfile/dependency.html
// http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html // http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
class MakePomSpec extends Specification { class MakePomSpec extends UnitSpec {
def is = s2""" // This is a specification to check the Ivy revision number conversion to pom.
This is a specification to check the Ivy revision number conversion to pom. "1.0" should "convert to 1.0" in convertTo("1.0", "1.0")
1.0 should "[1.0,2.0]" should "convert to [1.0,2.0]" in {
${convertTo("1.0", "1.0")} convertTo("[1.0,2.0]", "[1.0,2.0]")
}
[1.0,2.0] should "[1.0,2.0[" should "convert to [1.0,2.0)" in {
${convertTo("[1.0,2.0]", "[1.0,2.0]")} convertTo("[1.0,2.0[", "[1.0,2.0)")
}
[1.0,2.0[ should "]1.0,2.0]" should "convert to (1.0,2.0]" in {
${convertTo("[1.0,2.0[", "[1.0,2.0)")} convertTo("]1.0,2.0]", "(1.0,2.0]")
}
]1.0,2.0] should "]1.0,2.0[" should "convert to (1.0,2.0)" in {
${convertTo("]1.0,2.0]", "(1.0,2.0]")} convertTo("]1.0,2.0[", "(1.0,2.0)")
}
]1.0,2.0[ should "[1.0,)" should "convert to [1.0,)" in {
${convertTo("]1.0,2.0[", "(1.0,2.0)")} convertTo("[1.0,)", "[1.0,)")
}
[1.0,) should "]1.0,)" should "convert to (1.0,)" in {
${convertTo("[1.0,)", "[1.0,)")} convertTo("]1.0,)", "(1.0,)")
}
]1.0,) should "(,2.0]" should "convert to (,2.0]" in {
${convertTo("]1.0,)", "(1.0,)")} convertTo("(,2.0]", "(,2.0]")
}
(,2.0] should "(,2.0[" should "convert to (,2.0)" in {
${convertTo("(,2.0]", "(,2.0]")} convertTo("(,2.0[", "(,2.0)")
}
(,2.0[ should "1.+" should "convert to [1,2)" in {
${convertTo("(,2.0[", "(,2.0)")} convertTo("1.+", "[1,2)")
}
1.+ should "1.2.3.4.+" should "convert to [1.2.3.4,1.2.3.5)" in {
${convertTo("1.+", "[1,2)")} convertTo("1.2.3.4.+", "[1.2.3.4,1.2.3.5)")
}
1.2.3.4.+ should "12.31.42.+" should "convert to [12.31.42,12.31.43)" in {
${convertTo("1.2.3.4.+", "[1.2.3.4,1.2.3.5)")} convertTo("12.31.42.+", "[12.31.42,12.31.43)")
}
12.31.42.+ should "1.1+" should "convert to [1.1,1.2),[1.10,1.20),[1.100,1.200),[1.1000,1.2000),[1.10000,1.20000)" in {
${convertTo("12.31.42.+", "[12.31.42,12.31.43)")} convertTo("1.1+", "[1.1,1.2),[1.10,1.20),[1.100,1.200),[1.1000,1.2000),[1.10000,1.20000)")
}
1.1+ should "1+" should "convert to [1,2),[10,20),[100,200),[1000,2000),[10000,20000)" in {
${convertTo("1.1+", "[1.1,1.2),[1.10,1.20),[1.100,1.200),[1.1000,1.2000),[1.10000,1.20000)")} convertTo("1+", "[1,2),[10,20),[100,200),[1000,2000),[10000,20000)")
}
1+ should "+" should "convert to [0,)" in convertTo("+", "[0,)")
${convertTo("1+", "[1,2),[10,20),[100,200),[1000,2000),[10000,20000)")}
+ should "foo+" should "convert to foo+" in beParsedAsError("foo+")
${convertTo("+", "[0,)")}
foo+ should
${beParsedAsError("foo+")}
"""
val mp = new MakePom(ConsoleLogger()) val mp = new MakePom(ConsoleLogger())
def convertTo(s: String, expected: String) = def convertTo(s: String, expected: String): Unit =
MakePom.makeDependencyVersion(s) must_== expected MakePom.makeDependencyVersion(s) shouldBe expected
def beParsedAsError(s: String) = def beParsedAsError(s: String): Unit =
try { intercept[Throwable] {
MakePom.makeDependencyVersion(s) MakePom.makeDependencyVersion(s)
failure
} catch {
case e: Throwable => success
} }
} }

View File

@ -1,24 +1,19 @@
import java.net.URL import java.net.URL
import org.specs2.mutable.Specification
import sbt._ import sbt._
import sbt.internal.util.UnitSpec
object ResolverTest extends Specification { object ResolverTest extends UnitSpec {
"Resolver" should { "Resolver url" should "propagate pattern descriptorOptional and skipConsistencyCheck." in {
"url" should { val pats = Seq("[orgPath]")
"propagate pattern descriptorOptional and skipConsistencyCheck." in { val patsExpected = Seq("http://foo.com/test/[orgPath]")
val pats = Seq("[orgPath]") val patterns = Resolver.url("test", new URL("http://foo.com/test"))(Patterns(pats, pats, isMavenCompatible = false, descriptorOptional = true, skipConsistencyCheck = true)).patterns
val patsExpected = Seq("http://foo.com/test/[orgPath]")
val patterns = Resolver.url("test", new URL("http://foo.com/test"))(Patterns(pats, pats, isMavenCompatible = false, descriptorOptional = true, skipConsistencyCheck = true)).patterns
patterns.ivyPatterns must equalTo(patsExpected) patterns.ivyPatterns shouldBe patsExpected
patterns.artifactPatterns must equalTo(patsExpected) patterns.artifactPatterns shouldBe patsExpected
patterns.isMavenCompatible must beFalse patterns.isMavenCompatible shouldBe false
patterns.skipConsistencyCheck must beTrue assert(patterns.skipConsistencyCheck)
patterns.descriptorOptional must beTrue assert(patterns.descriptorOptional)
}
}
} }
} }

View File

@ -1,112 +1,93 @@
package sbt package sbt
import org.specs2._ import sbt.internal.util.UnitSpec
class VersionNumberSpec extends Specification { // This is a specification to check the version number parsing.
def is = s2""" class VersionNumberSpec extends UnitSpec {
"1" should "be parsed" in beParsedAs("1", Seq(1), Seq(), Seq())
it should "breakdown" in breakDownTo("1", Some(1))
it should "cascade" in generateCorrectCascadingNumbers("1", Seq("1"))
This is a specification to check the version number parsing. "1.0" should "be parsed" in beParsedAs("1.0", Seq(1, 0), Seq(), Seq())
it should "breakdown" in breakDownTo("1.0", Some(1), Some(0))
it should "cascade" in generateCorrectCascadingNumbers("1.0", Seq("1.0"))
1 should "1.0.0" should "be parsed" in beParsedAs("1.0.0", Seq(1, 0, 0), Seq(), Seq())
${beParsedAs("1", Seq(1), Seq(), Seq())} it should "breakdown" in breakDownTo("1.0.0", Some(1), Some(0), Some(0))
${breakDownTo("1", Some(1))} it should "cascade" in generateCorrectCascadingNumbers("1.0.0", Seq("1.0.0", "1.0"))
${generateCorrectCascadingNumbers("1", Seq("1"))} it should "be SemVer compat with 1.0.1" in beSemVerCompatWith("1.0.0", "1.0.1")
it should "be SemVer compat with 1.1.1" in beSemVerCompatWith("1.0.0", "1.1.1")
it should "not be SemVer compat with 2.0.0" in notBeSemVerCompatWith("1.0.0", "2.0.0")
it should "not be SemVer compat with 1.0.0-M1" in notBeSemVerCompatWith("1.0.0", "1.0.0-M1")
it should "be SecSeg compat with 1.0.1" in beSecSegCompatWith("1.0.0", "1.0.1")
it should "not be SecSeg compat with 1.1.1" in notBeSecSegCompatWith("1.0.0", "1.1.1")
it should "not be SecSeg compat with 2.0.0" in notBeSecSegCompatWith("1.0.0", "2.0.0")
it should "not be SecSeg compat with 1.0.0-M1" in notBeSecSegCompatWith("1.0.0", "1.0.0-M1")
1.0 should "1.0.0.0" should "be parsed" in beParsedAs("1.0.0.0", Seq(1, 0, 0, 0), Seq(), Seq())
${beParsedAs("1.0", Seq(1, 0), Seq(), Seq())} it should "breakdown" in breakDownTo("1.0.0.0", Some(1), Some(0), Some(0), Some(0))
${breakDownTo("1.0", Some(1), Some(0))} it should "cascade" in generateCorrectCascadingNumbers("1.0.0.0", Seq("1.0.0.0", "1.0.0", "1.0"))
${generateCorrectCascadingNumbers("1.0", Seq("1.0"))}
1.0.0 should "0.12.0" should "be parsed" in beParsedAs("0.12.0", Seq(0, 12, 0), Seq(), Seq())
${beParsedAs("1.0.0", Seq(1, 0, 0), Seq(), Seq())} it should "breakdown" in breakDownTo("0.12.0", Some(0), Some(12), Some(0))
${breakDownTo("1.0.0", Some(1), Some(0), Some(0))} it should "cascade" in generateCorrectCascadingNumbers("0.12.0", Seq("0.12.0", "0.12"))
${generateCorrectCascadingNumbers("1.0.0", Seq("1.0.0", "1.0"))} it should "not be SemVer compat with 0.12.0-RC1" in notBeSemVerCompatWith("0.12.0", "0.12.0-RC1")
it should "not be SemVer compat with 0.12.1" in notBeSemVerCompatWith("0.12.0", "0.12.1")
it should "not be SemVer compat with 0.12.1-M1" in notBeSemVerCompatWith("0.12.0", "0.12.1-M1")
it should "not be SecSeg compat with 0.12.0-RC1" in notBeSecSegCompatWith("0.12.0", "0.12.0-RC1")
it should "be SecSeg compat with 0.12.1" in beSecSegCompatWith("0.12.0", "0.12.1")
it should "be SecSeg compat with 0.12.1-M1" in beSecSegCompatWith("0.12.0", "0.12.1-M1")
${beSemVerCompatWith("1.0.0", "1.0.1")} "0.1.0-SNAPSHOT" should "be parsed" in beParsedAs("0.1.0-SNAPSHOT", Seq(0, 1, 0), Seq("SNAPSHOT"), Seq())
${beSemVerCompatWith("1.0.0", "1.1.1")} it should "cascade" in generateCorrectCascadingNumbers("0.1.0-SNAPSHOT", Seq("0.1.0-SNAPSHOT", "0.1.0", "0.1"))
${notBeSemVerCompatWith("1.0.0", "2.0.0")} it should "be SemVer compat with 0.1.0-SNAPSHOT" in beSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT")
${notBeSemVerCompatWith("1.0.0", "1.0.0-M1")} it should "not be SemVer compat with 0.1.0" in notBeSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0")
it should "be SemVer compat with 0.1.0-SNAPSHOT+001" in beSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT+001")
it should "be SecSeg compat with 0.1.0-SNAPSHOT" in beSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT")
it should "be not SecSeg compat with 0.1.0" in notBeSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0")
it should "be SecSeg compat with 0.1.0-SNAPSHOT+001" in beSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT+001")
${beSecSegCompatWith("1.0.0", "1.0.1")} "0.1.0-M1" should "be parsed" in beParsedAs("0.1.0-M1", Seq(0, 1, 0), Seq("M1"), Seq())
${notBeSecSegCompatWith("1.0.0", "1.1.1")} it should "cascade" in generateCorrectCascadingNumbers("0.1.0-M1", Seq("0.1.0-M1", "0.1.0", "0.1"))
${notBeSecSegCompatWith("1.0.0", "2.0.0")}
${notBeSecSegCompatWith("1.0.0", "1.0.0-M1")}
1.0.0.0 should "0.1.0-RC1" should "be parsed" in beParsedAs("0.1.0-RC1", Seq(0, 1, 0), Seq("RC1"), Seq())
${beParsedAs("1.0.0.0", Seq(1, 0, 0, 0), Seq(), Seq())} it should "cascade" in generateCorrectCascadingNumbers("0.1.0-RC1", Seq("0.1.0-RC1", "0.1.0", "0.1"))
${breakDownTo("1.0.0.0", Some(1), Some(0), Some(0), Some(0))}
${generateCorrectCascadingNumbers("1.0.0.0", Seq("1.0.0.0", "1.0.0", "1.0"))}
0.12.0 should "0.1.0-MSERVER-1" should "be parsed" in beParsedAs("0.1.0-MSERVER-1", Seq(0, 1, 0), Seq("MSERVER", "1"), Seq())
${beParsedAs("0.12.0", Seq(0, 12, 0), Seq(), Seq())} it should "cascade" in generateCorrectCascadingNumbers("0.1.0-MSERVER-1", Seq("0.1.0-MSERVER-1", "0.1.0", "0.1"))
${breakDownTo("0.12.0", Some(0), Some(12), Some(0))}
${generateCorrectCascadingNumbers("0.12.0", Seq("0.12.0", "0.12"))}
${notBeSemVerCompatWith("0.12.0", "0.12.0-RC1")}
${notBeSemVerCompatWith("0.12.0", "0.12.1")}
${notBeSemVerCompatWith("0.12.0", "0.12.1-M1")}
${notBeSecSegCompatWith("0.12.0", "0.12.0-RC1")}
${beSecSegCompatWith("0.12.0", "0.12.1")}
${beSecSegCompatWith("0.12.0", "0.12.1-M1")}
0.1.0-SNAPSHOT should
${beParsedAs("0.1.0-SNAPSHOT", Seq(0, 1, 0), Seq("SNAPSHOT"), Seq())}
${generateCorrectCascadingNumbers("0.1.0-SNAPSHOT", Seq("0.1.0-SNAPSHOT", "0.1.0", "0.1"))}
${beSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT")}
${notBeSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0")}
${beSemVerCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT+001")}
${beSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT")}
${notBeSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0")}
${beSecSegCompatWith("0.1.0-SNAPSHOT", "0.1.0-SNAPSHOT+001")}
0.1.0-M1 should
${beParsedAs("0.1.0-M1", Seq(0, 1, 0), Seq("M1"), Seq())}
${generateCorrectCascadingNumbers("0.1.0-M1", Seq("0.1.0-M1", "0.1.0", "0.1"))}
0.1.0-RC1 should
${beParsedAs("0.1.0-RC1", Seq(0, 1, 0), Seq("RC1"), Seq())}
${generateCorrectCascadingNumbers("0.1.0-RC1", Seq("0.1.0-RC1", "0.1.0", "0.1"))}
0.1.0-MSERVER-1 should
${beParsedAs("0.1.0-MSERVER-1", Seq(0, 1, 0), Seq("MSERVER", "1"), Seq())}
${generateCorrectCascadingNumbers("0.1.0-MSERVER-1", Seq("0.1.0-MSERVER-1", "0.1.0", "0.1"))}
2.10.4-20140115-000117-b3a-sources should "2.10.4-20140115-000117-b3a-sources" should "be parsed" in {
${beParsedAs("2.10.4-20140115-000117-b3a-sources", Seq(2, 10, 4), Seq("20140115", "000117", "b3a", "sources"), Seq())} beParsedAs("2.10.4-20140115-000117-b3a-sources", Seq(2, 10, 4), Seq("20140115", "000117", "b3a", "sources"), Seq())
${generateCorrectCascadingNumbers("2.10.4-20140115-000117-b3a-sources", Seq("2.10.4-20140115-000117-b3a-sources", "2.10.4", "2.10"))} }
it should "cascade" in generateCorrectCascadingNumbers("2.10.4-20140115-000117-b3a-sources", Seq("2.10.4-20140115-000117-b3a-sources", "2.10.4", "2.10"))
it should "be SemVer compat with 2.0.0" in beSemVerCompatWith("2.10.4-20140115-000117-b3a-sources", "2.0.0")
it should "be not SecSeg compat with 2.0.0" in notBeSecSegCompatWith("2.10.4-20140115-000117-b3a-sources", "2.0.0")
${beSemVerCompatWith("2.10.4-20140115-000117-b3a-sources", "2.0.0")} "20140115000117-b3a-sources" should "be parsed" in {
beParsedAs("20140115000117-b3a-sources", Seq(20140115000117L), Seq("b3a", "sources"), Seq())
}
it should "cascade" in generateCorrectCascadingNumbers("20140115000117-b3a-sources", Seq("20140115000117-b3a-sources"))
${notBeSecSegCompatWith("2.10.4-20140115-000117-b3a-sources", "2.0.0")} "1.0.0-alpha+001+002" should "be parsed" in {
beParsedAs("1.0.0-alpha+001+002", Seq(1, 0, 0), Seq("alpha"), Seq("+001", "+002"))
}
it should "cascade" in generateCorrectCascadingNumbers("1.0.0-alpha+001+002", Seq("1.0.0-alpha+001+002", "1.0.0", "1.0"))
20140115000117-b3a-sources should "non.space.!?string" should "be parsed" in {
${beParsedAs("20140115000117-b3a-sources", Seq(20140115000117L), Seq("b3a", "sources"), Seq())} beParsedAs("non.space.!?string", Seq(), Seq(), Seq("non.space.!?string"))
${generateCorrectCascadingNumbers("20140115000117-b3a-sources", Seq("20140115000117-b3a-sources"))} }
it should "cascade" in generateCorrectCascadingNumbers("non.space.!?string", Seq("non.space.!?string"))
1.0.0-alpha+001+002 should "space !?string" should "be parsed as an error" in beParsedAsError("space !?string")
${beParsedAs("1.0.0-alpha+001+002", Seq(1, 0, 0), Seq("alpha"), Seq("+001", "+002"))} "blank string" should "be parsed as an error" in beParsedAsError("")
${generateCorrectCascadingNumbers("1.0.0-alpha+001+002", Seq("1.0.0-alpha+001+002", "1.0.0", "1.0"))}
non.space.!?string should
${beParsedAs("non.space.!?string", Seq(), Seq(), Seq("non.space.!?string"))}
${generateCorrectCascadingNumbers("non.space.!?string", Seq("non.space.!?string"))}
space !?string should
${beParsedAsError("space !?string")}
blank string should
${beParsedAsError("")}
"""
def beParsedAs(s: String, ns: Seq[Long], ts: Seq[String], es: Seq[String]) = def beParsedAs(s: String, ns: Seq[Long], ts: Seq[String], es: Seq[String]) =
s match { s match {
case VersionNumber(ns1, ts1, es1) if (ns1 == ns && ts1 == ts && es1 == es) => case VersionNumber(ns1, ts1, es1) if (ns1 == ns && ts1 == ts && es1 == es) =>
(VersionNumber(ns, ts, es).toString must_== s) and (VersionNumber(ns, ts, es).toString shouldBe s)
(VersionNumber(ns, ts, es) == VersionNumber(ns, ts, es)) (VersionNumber(ns, ts, es) shouldBe VersionNumber(ns, ts, es))
case VersionNumber(ns1, ts1, es1) => case VersionNumber(ns1, ts1, es1) =>
sys.error(s"$ns1, $ts1, $es1") sys.error(s"$ns1, $ts1, $es1")
} }
@ -115,26 +96,26 @@ class VersionNumberSpec extends Specification {
s match { s match {
case VersionNumber(ns, ts, es) => case VersionNumber(ns, ts, es) =>
val v = VersionNumber(ns, ts, es) val v = VersionNumber(ns, ts, es)
(v._1 must_== major) and (v._1 shouldBe major)
(v._2 must_== minor) and (v._2 shouldBe minor)
(v._3 must_== patch) and (v._3 shouldBe patch)
(v._4 must_== buildNumber) (v._4 shouldBe buildNumber)
} }
def beParsedAsError(s: String) = def beParsedAsError(s: String): Unit =
s match { s match {
case VersionNumber(ns1, ts1, es1) => failure case VersionNumber(ns1, ts1, es1) => sys.error(s)
case _ => success case _ => ()
} }
def beSemVerCompatWith(v1: String, v2: String) = def beSemVerCompatWith(v1: String, v2: String) =
VersionNumber.SemVer.isCompatible(VersionNumber(v1), VersionNumber(v2)) must_== true VersionNumber.SemVer.isCompatible(VersionNumber(v1), VersionNumber(v2)) shouldBe true
def notBeSemVerCompatWith(v1: String, v2: String) = def notBeSemVerCompatWith(v1: String, v2: String) =
VersionNumber.SemVer.isCompatible(VersionNumber(v1), VersionNumber(v2)) must_== false VersionNumber.SemVer.isCompatible(VersionNumber(v1), VersionNumber(v2)) shouldBe false
def beSecSegCompatWith(v1: String, v2: String) = def beSecSegCompatWith(v1: String, v2: String) =
VersionNumber.SecondSegment.isCompatible(VersionNumber(v1), VersionNumber(v2)) must_== true VersionNumber.SecondSegment.isCompatible(VersionNumber(v1), VersionNumber(v2)) shouldBe true
def notBeSecSegCompatWith(v1: String, v2: String) = def notBeSecSegCompatWith(v1: String, v2: String) =
VersionNumber.SecondSegment.isCompatible(VersionNumber(v1), VersionNumber(v2)) must_== false VersionNumber.SecondSegment.isCompatible(VersionNumber(v1), VersionNumber(v2)) shouldBe false
def generateCorrectCascadingNumbers(s: String, ns: Seq[String]) = { def generateCorrectCascadingNumbers(s: String, ns: Seq[String]) = {
val versionNumbers = ns.toVector map VersionNumber.apply val versionNumbers = ns.toVector map VersionNumber.apply
VersionNumber(s).cascadingVersions must_== versionNumbers VersionNumber(s).cascadingVersions shouldBe versionNumbers
} }
} }

View File

@ -5,11 +5,12 @@ 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"
val utilVersion = "0.1.0-M1" val utilVersion = "0.1.0-M2"
val ioVersion = "1.0.0-M1" val ioVersion = "1.0.0-M3"
lazy val sbtIO = "org.scala-sbt" %% "io" % ioVersion lazy val sbtIO = "org.scala-sbt" %% "io" % ioVersion
lazy val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion lazy val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion
lazy val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion lazy val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion
lazy val utilTesting = "org.scala-sbt" %% "util-testing" % utilVersion
lazy val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.0-M1" lazy val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.0-M1"
lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-927bc9ded7f8fba63297cddd0d5a3d01d6ad5d8d" lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-927bc9ded7f8fba63297cddd0d5a3d01d6ad5d8d"