Merge pull request #1391 from sbt/wip/1390

Improve test failure message for #1390.
This commit is contained in:
eugene yokota 2014-06-06 13:24:11 -04:00
commit 47b5790c41
3 changed files with 10 additions and 39 deletions

View File

@ -29,7 +29,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
},
@ -48,12 +48,12 @@ object Sbt extends Build {
// TODO - To some extent these should take args to figure out what to do.
commands += Command.command("release-libs-211") { state =>
"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-local") { state =>
"publishLocal" ::

View File

@ -5,6 +5,7 @@ import java.io.File
import java.net.URLClassLoader
import java.util.HashMap
// Hack for testing only
private[sbt] final class ClassLoaderCache(val commonParent: ClassLoader) {
private[this] val delegate = new HashMap[List[File], Reference[CachedClassLoader]]
@ -25,9 +26,9 @@ private[sbt] final class ClassLoaderCache(val commonParent: ClassLoader) {
get(files, stamps, existingRef.get)
private[this] def get(files: List[File], stamps: List[Long], existing: CachedClassLoader): ClassLoader =
if (existing == null || stamps != existing.timestamps)
if (existing == null || stamps != existing.timestamps) {
newEntry(files, stamps)
else
} else
existing.loader
private[this] def newEntry(files: List[File], stamps: List[Long]): ClassLoader =

View File

@ -1,30 +0,0 @@
package sbt
package classpath
import org.scalacheck._
import Prop._
import java.io.File
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)
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)
}
}
private[this] def withcp[T](names: List[String])(f: List[File] => T): T = IO.withTemporaryDirectory { tmp =>
val files = names.map { name =>
val file = new File(tmp, name)
IO.touch(file)
file
}
f(files)
}
private[this] def sameClassLoader(loaders: Seq[ClassLoader]): Boolean = loaders.size < 2 ||
loaders.sliding(2).forall { case Seq(x, y) => x == y }
}