Skip to content

Commit

Permalink
=pro #3753 Override dependency versions from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
bantonsson committed Dec 3, 2013
1 parent 4d05253 commit 00a268b
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}

Expand All @@ -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}")
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions akka-docs/rst/scala/code/docs/future/FutureDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {}
}
8 changes: 3 additions & 5 deletions akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
62 changes: 50 additions & 12 deletions project/AkkaBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
)
Expand Down Expand Up @@ -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
)
)
Expand All @@ -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

Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 00a268b

Please sign in to comment.