From 2c3f40eb02fe108bf99a139b988adbb7a6735ae0 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 2 Jun 2014 15:10:17 -0400 Subject: [PATCH] Improve test failure message for #1390. --- project/Sbt.scala | 14 +++++++------- .../test/scala/sbt/classpath/ConcurrentCache.scala | 13 ++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/project/Sbt.scala b/project/Sbt.scala index f22136d94..1633d6d71 100644 --- a/project/Sbt.scala +++ b/project/Sbt.scala @@ -25,7 +25,7 @@ object Sbt extends Build { javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"), incOptions := incOptions.value.withNameHashing(true), commands += Command.command("setupBuildScala211") { state => - """set scalaVersion in ThisBuild := "2.11.0" """ :: + """set scalaVersion in ThisBuild := "2.11.1" """ :: "set Util.includeTestDependencies in ThisBuild := true" :: state }, @@ -46,12 +46,12 @@ object Sbt extends Build { def lameAgregateTask(task: String): String = s"all control/$task collections/$task io/$task completion/$task" "setupBuildScala211" :: - /// First test - lameAgregateTask("test") :: - // Note: You need the sbt-pgp plugin installed to release. - lameAgregateTask("publishSigned") :: - // Now restore the defaults. - "reload" :: state + /// First test + lameAgregateTask("test") :: + // Note: You need the sbt-pgp plugin installed to release. + lameAgregateTask("publishSigned") :: + // Now restore the defaults. + "reload" :: state }, commands += Command.command("release-sbt") { state => // TODO - Any sort of validation diff --git a/util/classpath/src/test/scala/sbt/classpath/ConcurrentCache.scala b/util/classpath/src/test/scala/sbt/classpath/ConcurrentCache.scala index ab2fa9ac9..470c1c8d5 100644 --- a/util/classpath/src/test/scala/sbt/classpath/ConcurrentCache.scala +++ b/util/classpath/src/test/scala/sbt/classpath/ConcurrentCache.scala @@ -9,11 +9,20 @@ object ConcurrentCache extends Properties("ClassLoaderCache concurrent access") implicit lazy val concurrentArb: Arbitrary[Int] = Arbitrary(Gen.choose(1, 1000)) implicit lazy val filenameArb: Arbitrary[String] = Arbitrary(Gen.alphaStr) + private[this] object DifferentClassloader { + def unapply(loaders: Seq[ClassLoader]): Option[(ClassLoader, ClassLoader)] = + if (loaders.size > 1) loaders.sliding(2).find { case Seq(x, y) => x != y } map { case Seq(x, y) => (x, y) } + else None + } + property("Same class loader for same classpaths concurrently processed") = forAll { (names: List[String], concurrent: Int) => withcp(names.distinct) { files => val cache = new ClassLoaderCache(null) val loaders = (1 to concurrent).par.map(_ => cache(files)).toList - sameClassLoader(loaders) + loaders match { + case DifferentClassloader(left, right) => false :| s"$left != $right" + case _ => true :| "" + } } } @@ -25,6 +34,4 @@ object ConcurrentCache extends Properties("ClassLoaderCache concurrent access") } f(files) } - private[this] def sameClassLoader(loaders: Seq[ClassLoader]): Boolean = loaders.size < 2 || - loaders.sliding(2).forall { case Seq(x, y) => x == y } } \ No newline at end of file