From 00a268b6b3ea17ee5e36198905484e46b30cb827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Antonsson?= Date: Tue, 3 Dec 2013 09:18:26 +0100 Subject: [PATCH] =pro #3753 Override dependency versions from command line --- .../akka/actor/dispatch/ActorModelSpec.scala | 2 +- .../test/scala/akka/dispatch/FutureSpec.scala | 9 ++- .../test/scala/akka/pattern/PatternSpec.scala | 6 +- .../akka/cluster/MultiNodeClusterSpec.scala | 22 +++---- .../akka/contrib/pattern/AggregatorSpec.scala | 4 +- .../code/docs/future/FutureDocSpec.scala | 5 +- .../scala/akka/remote/QuietReporter.scala | 5 +- .../test/scala/akka/testkit/AkkaSpec.scala | 8 +-- project/AkkaBuild.scala | 62 +++++++++++++++---- 9 files changed, 78 insertions(+), 45 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala index 4cf06127e8b..08c086b58a5 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala @@ -10,7 +10,7 @@ import java.util.concurrent.{ TimeUnit, CountDownLatch, ConcurrentHashMap } import java.util.concurrent.atomic.{ AtomicLong, AtomicInteger } import org.junit.runner.RunWith -import org.scalatest.Assertions.{ fail, assert } +import org.scalatest.Assertions._ import org.scalatest.junit.JUnitRunner import com.typesafe.config.Config diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 59cbb80ed97..28a85734c60 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -7,10 +7,9 @@ import org.scalatest.prop.Checkers import org.scalacheck._ import org.scalacheck.Arbitrary._ import org.scalacheck.Prop._ -import org.scalacheck.Gen._ import akka.actor._ -import akka.testkit.{ EventFilter, filterEvents, filterException, AkkaSpec, DefaultTimeout, TestLatch } -import scala.concurrent.{ Await, Awaitable, Future, Promise, ExecutionContext } +import akka.testkit.{ EventFilter, filterException, AkkaSpec, DefaultTimeout, TestLatch } +import scala.concurrent.{ Await, Awaitable, Future, Promise } import scala.util.control.NonFatal import scala.concurrent.duration._ import scala.concurrent.ExecutionContext @@ -730,14 +729,14 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa val genIntAction = for { n ← arbitrary[Int] - a ← oneOf(IntAdd(n), IntSub(n), IntMul(n), IntDiv(n)) + a ← Gen.oneOf(IntAdd(n), IntSub(n), IntMul(n), IntDiv(n)) } yield a val genMapAction = genIntAction map (MapAction(_)) val genFlatMapAction = genIntAction map (FlatMapAction(_)) - oneOf(genMapAction, genFlatMapAction) + Gen.oneOf(genMapAction, genFlatMapAction) } diff --git a/akka-actor-tests/src/test/scala/akka/pattern/PatternSpec.scala b/akka-actor-tests/src/test/scala/akka/pattern/PatternSpec.scala index 4da15664ede..67b2f008859 100644 --- a/akka-actor-tests/src/test/scala/akka/pattern/PatternSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/pattern/PatternSpec.scala @@ -52,14 +52,16 @@ class PatternSpec extends AkkaSpec("akka.actor.serialize-messages = off") { "pattern.after" must { "be completed successfully eventually" in { - val f = after(1 second, using = system.scheduler)(Promise.successful(5).future) + // TODO after is unfortunately shadowed by ScalaTest, fix as part of #3759 + val f = akka.pattern.after(1 second, using = system.scheduler)(Promise.successful(5).future) val r = Future.firstCompletedOf(Seq(Promise[Int]().future, f)) Await.result(r, remaining) must be(5) } "be completed abnormally eventually" in { - val f = after(1 second, using = system.scheduler)(Promise.failed(new IllegalStateException("Mexico")).future) + // TODO after is unfortunately shadowed by ScalaTest, fix as part of #3759 + val f = akka.pattern.after(1 second, using = system.scheduler)(Promise.failed(new IllegalStateException("Mexico")).future) val r = Future.firstCompletedOf(Seq(Promise[Int]().future, f)) intercept[IllegalStateException] { Await.result(r, remaining) }.getMessage must be("Mexico") diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/MultiNodeClusterSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/MultiNodeClusterSpec.scala index 0bb8ba6fc17..f1265cb481d 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/MultiNodeClusterSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/MultiNodeClusterSpec.scala @@ -4,8 +4,8 @@ package akka.cluster import language.implicitConversions -import org.scalatest.Suite -import org.scalatest.exceptions.TestFailedException +import org.scalatest.{ Suite, Outcome, Canceled } +import org.scalatest.exceptions.TestCanceledException import com.typesafe.config.Config import com.typesafe.config.ConfigFactory import akka.remote.testconductor.RoleName @@ -162,19 +162,15 @@ trait MultiNodeClusterSpec extends Suite with STMultiNodeSpec with WatchedByCoro // it will most likely not be possible to run next step. This ensures // fail fast of steps after the first failure. private var failed = false - override protected def withFixture(test: NoArgTest): Unit = try { + override protected def withFixture(test: NoArgTest): Outcome = if (failed) { - val e = new TestFailedException("Previous step failed", 0) - // short stack trace - e.setStackTrace(e.getStackTrace.take(1)) - throw e + Canceled(new TestCanceledException("Previous step failed", 0)) + } else { + val out = super.withFixture(test) + if (!out.isSucceeded) + failed = true + out } - super.withFixture(test) - } catch { - case t: Throwable ⇒ - failed = true - throw t - } def clusterView: ClusterReadView = cluster.readView diff --git a/akka-contrib/src/test/scala/akka/contrib/pattern/AggregatorSpec.scala b/akka-contrib/src/test/scala/akka/contrib/pattern/AggregatorSpec.scala index cd50a026544..22a0810edf4 100644 --- a/akka-contrib/src/test/scala/akka/contrib/pattern/AggregatorSpec.scala +++ b/akka-contrib/src/test/scala/akka/contrib/pattern/AggregatorSpec.scala @@ -195,7 +195,7 @@ class AggregatorSpec extends TestKit(ActorSystem("test")) with ImplicitSender wi case result: List[_] ⇒ result should have size 1 case result ⇒ - assert(condition = false, s"Expect List, got ${result.getClass}") + assert(false, s"Expect List, got ${result.getClass}") } } @@ -206,7 +206,7 @@ class AggregatorSpec extends TestKit(ActorSystem("test")) with ImplicitSender wi case result: List[_] ⇒ result should have size 3 case result ⇒ - assert(condition = false, s"Expect List, got ${result.getClass}") + assert(false, s"Expect List, got ${result.getClass}") } } } diff --git a/akka-docs/rst/scala/code/docs/future/FutureDocSpec.scala b/akka-docs/rst/scala/code/docs/future/FutureDocSpec.scala index 18a8a27caf6..485eb3d4fff 100644 --- a/akka-docs/rst/scala/code/docs/future/FutureDocSpec.scala +++ b/akka-docs/rst/scala/code/docs/future/FutureDocSpec.scala @@ -418,9 +418,10 @@ class FutureDocSpec extends AkkaSpec { "demonstrate usage of pattern.after" in { //#after - import akka.pattern.after + // TODO after is unfortunately shadowed by ScalaTest, fix as part of #3759 + // import akka.pattern.after - val delayed = after(200 millis, using = system.scheduler)(Future.failed( + val delayed = akka.pattern.after(200 millis, using = system.scheduler)(Future.failed( new IllegalStateException("OHNOES"))) val future = Future { Thread.sleep(1000); "foo" } val result = Future firstCompletedOf Seq(future, delayed) diff --git a/akka-remote-tests/src/test/scala/akka/remote/QuietReporter.scala b/akka-remote-tests/src/test/scala/akka/remote/QuietReporter.scala index 1fb66414233..aed29bc7473 100644 --- a/akka-remote-tests/src/test/scala/akka/remote/QuietReporter.scala +++ b/akka-remote-tests/src/test/scala/akka/remote/QuietReporter.scala @@ -8,13 +8,12 @@ import org.scalatest.tools.StandardOutReporter import org.scalatest.events._ import java.lang.Boolean.getBoolean -class QuietReporter(inColor: Boolean, withDurations: Boolean = false) extends StandardOutReporter(withDurations, inColor, false, true) { +class QuietReporter(inColor: Boolean, withDurations: Boolean = false) extends StandardOutReporter(withDurations, inColor, false, true, false, false, false, false, false) { + def this() = this(!getBoolean("akka.test.nocolor"), !getBoolean("akka.test.nodurations")) override def apply(event: Event): Unit = event match { case _: RunStarting ⇒ () case _ ⇒ super.apply(event) } - - override def makeFinalReport(resourceName: String, duration: Option[Long], summaryOption: Option[Summary]) {} } diff --git a/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala b/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala index 39d24c8164e..bc575704272 100644 --- a/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala +++ b/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala @@ -5,16 +5,14 @@ package akka.testkit import language.{ postfixOps, reflectiveCalls } -import org.scalatest.{ WordSpecLike, BeforeAndAfterAll, Tag } +import org.scalatest.{ WordSpecLike, BeforeAndAfterAll } import org.scalatest.matchers.MustMatchers -import akka.actor.{ Actor, Props, ActorSystem, PoisonPill, DeadLetter, ActorSystemImpl } +import akka.actor.ActorSystem import akka.event.{ Logging, LoggingAdapter } import scala.concurrent.duration._ -import scala.concurrent.{ Await, Future } +import scala.concurrent.Future import com.typesafe.config.{ Config, ConfigFactory } -import java.util.concurrent.TimeoutException import akka.dispatch.Dispatchers -import akka.pattern.ask import akka.testkit.TestEvent._ object AkkaSpec { diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 9c7ed8a5522..f095e71878a 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -43,7 +43,7 @@ object AkkaBuild extends Build { version := "2.3-SNAPSHOT", // Also change ScalaVersion in akka-sbt-plugin/sample/project/Build.scala scalaVersion := requestedScalaVersion, - scalaBinaryVersion <<= (scalaVersion, scalaBinaryVersion)((v, bv) => System.getProperty("akka.scalaBinaryVersion", if (v contains "-") v else bv)) + scalaBinaryVersion := System.getProperty("akka.scalaBinaryVersion", if (scalaVersion.value contains "-") scalaVersion.value else scalaBinaryVersion.value) ) lazy val akka = Project( @@ -83,6 +83,15 @@ object AkkaBuild extends Build { multiNodeTestkit) ) + lazy val akkaScalaNightly = Project( + id = "akka-scala-nightly", + base = file("akka-scala-nightly"), + // remove dependencies that we have to build ourselves (Scala STM, ZeroMQ Scala Bindings) + aggregate = Seq(actor, testkit, actorTests, dataflow, remote, remoteTests, camel, cluster, slf4j, + persistence, mailboxes, kernel, akkaSbtPlugin, osgi, osgiAries, contrib, samples, channels, channelsTests, + multiNodeTestkit) + ) + // this detached pseudo-project is used for running the tests against a different Scala version than the one used for compilation // usage: // all-tests/test (or test-only) @@ -428,7 +437,7 @@ object AkkaBuild extends Build { publishTo <<= Publish.akkaPluginPublishTo, scalacOptions in Compile := Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"), scalaVersion := "2.10.2", - scalaBinaryVersion <<= scalaVersion, + scalaBinaryVersion := "2.10", reportBinaryIssues := () // disable bin comp check ) ) @@ -624,18 +633,24 @@ object AkkaBuild extends Build { base = file("akka-channels"), dependencies = Seq(actor), settings = defaultSettings ++ scaladocSettings ++ experimentalSettings ++ Seq( - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _), + libraryDependencies +=("org.scala-lang" % "scala-reflect" % scalaVersion.value), reportBinaryIssues := () // disable bin comp check ) ) + // // this issue will be fixed in M8, for now we need to exclude M6, M7 modules used to compile the compiler + def excludeOldModules(m: ModuleID) = List("M6", "M7").foldLeft(m) { (mID, mStone) => + val version = s"2.11.0-$mStone" + mID.exclude("org.scala-lang.modules", s"scala-parser-combinators_$version").exclude("org.scala-lang.modules", s"scala-xml_$version") + } + lazy val channelsTests = Project( id = "akka-channels-tests", base = file("akka-channels-tests"), dependencies = Seq(channels, testkit % "compile;test->test"), settings = defaultSettings ++ experimentalSettings ++ Seq( publishArtifact in Compile := false, - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _), + libraryDependencies += excludeOldModules("org.scala-lang" % "scala-compiler" % scalaVersion.value), reportBinaryIssues := () // disable bin comp check ) ) @@ -647,7 +662,8 @@ object AkkaBuild extends Build { buildSettings ++ Seq( shellPrompt := { s => Project.extract(s).currentProject.id + " > " } - ) + ) ++ + resolverSettings lazy val baseSettings = Defaults.defaultSettings ++ Publish.settings @@ -730,7 +746,19 @@ object AkkaBuild extends Build { (if (useOnlyTestTags.isEmpty) Seq.empty else Seq("-n", if (multiNodeEnabled) useOnlyTestTags.mkString("\"", " ", "\"") else useOnlyTestTags.mkString(" "))) } - lazy val defaultSettings = baseSettings ++ formatSettings ++ mimaSettings ++ lsSettings ++ + lazy val resolverSettings = { + // should we be allowed to use artifacts published to the local maven repository + if(System.getProperty("akka.build.useLocalMavenResolver", "false").toBoolean) + Seq(resolvers += Resolver.mavenLocal) + else Seq.empty + } ++ { + // should we be allowed to use artifacts from sonatype snapshots + if(System.getProperty("akka.build.useSnapshotSonatypeResolver", "false").toBoolean) + Seq(resolvers += Resolver.sonatypeRepo("snapshots")) + else Seq.empty + } + + lazy val defaultSettings = baseSettings ++ formatSettings ++ mimaSettings ++ lsSettings ++ resolverSettings ++ Protobuf.settings ++ Seq( // compile options scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"), @@ -1053,17 +1081,27 @@ object AkkaBuild extends Build { object Dependencies { + object Versions { + val scalaStmVersion = System.getProperty("akka.build.scalaStmVersion", "0.7") + val scalaZeroMQVersion = System.getProperty("akka.build.scalaZeroMQVersion", "0.0.7") + val genJavaDocVersion = System.getProperty("akka.build.genJavaDocVersion", "0.5") + val scalaTestVersion = System.getProperty("akka.build.scalaTestVersion", "2.0") + val scalaCheckVersion = System.getProperty("akka.build.scalaCheckVersion", "1.10.1") + } + object Compile { + import Versions._ + // Compile val camelCore = "org.apache.camel" % "camel-core" % "2.10.3" exclude("org.slf4j", "slf4j-api") // ApacheV2 val config = "com.typesafe" % "config" % "1.0.2" // ApacheV2 val netty = "io.netty" % "netty" % "3.6.6.Final" // ApacheV2 val protobuf = "com.google.protobuf" % "protobuf-java" % "2.5.0" // New BSD - val scalaStm = "org.scala-stm" %% "scala-stm" % "0.7" // Modified BSD (Scala) + val scalaStm = "org.scala-stm" %% "scala-stm" % scalaStmVersion // Modified BSD (Scala) val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.2" // MIT - val zeroMQClient = "org.zeromq" %% "zeromq-scala-binding" % "0.0.7" // ApacheV2 + val zeroMQClient = "org.zeromq" %% "zeromq-scala-binding" % scalaZeroMQVersion // ApacheV2 val uncommonsMath = "org.uncommons.maths" % "uncommons-maths" % "1.2.2a" exclude("jfree", "jcommon") exclude("jfree", "jfreechart") // ApacheV2 val ariesBlueprint = "org.apache.aries.blueprint" % "org.apache.aries.blueprint" % "1.1.0" // ApacheV2 val osgiCore = "org.osgi" % "org.osgi.core" % "4.2.0" // ApacheV2 @@ -1078,7 +1116,7 @@ object Dependencies { val sigar = "org.fusesource" % "sigar" % "1.6.4" // ApacheV2 // Compiler plugins - val genjavadoc = compilerPlugin("com.typesafe.genjavadoc" %% "genjavadoc-plugin" % "0.5" cross CrossVersion.full) // ApacheV2 + val genjavadoc = compilerPlugin("com.typesafe.genjavadoc" %% "genjavadoc-plugin" % genJavaDocVersion cross CrossVersion.full) // ApacheV2 // Test @@ -1090,9 +1128,9 @@ object Dependencies { val logback = "ch.qos.logback" % "logback-classic" % "1.0.7" % "test" // EPL 1.0 / LGPL 2.1 val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" // MIT // changing the scalatest dependency must be reflected in akka-docs/rst/dev/multi-jvm-testing.rst - val scalatest = "org.scalatest" %% "scalatest" % "1.9.2-SNAP2" % "test" // ApacheV2 - val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.0" % "test" // New BSD - val ariesProxy = "org.apache.aries.proxy" % "org.apache.aries.proxy.impl" % "1.0.1" % "test" // ApacheV2 + val scalatest = "org.scalatest" %% "scalatest" % scalaTestVersion % "test" // ApacheV2 + val scalacheck = "org.scalacheck" %% "scalacheck" % scalaCheckVersion % "test" // New BSD + val ariesProxy = "org.apache.aries.proxy" % "org.apache.aries.proxy.impl" % "1.0.1" % "test" // ApacheV2 val pojosr = "com.googlecode.pojosr" % "de.kalpatec.pojosr.framework" % "0.1.4" % "test" // ApacheV2 val tinybundles = "org.ops4j.pax.tinybundles" % "tinybundles" % "1.0.0" % "test" // ApacheV2 val log4j = "log4j" % "log4j" % "1.2.14" % "test" // ApacheV2