Fix ScalaLibrary again

I was benchmarking sbt with turbo mode on and found that tests weren't
running. This was because we were inadvertently excluding all of the
dependency jars from the dynamic classpath. I have no idea why the
scripted tests didn't catch this.

The scalatest scripted test didn't catch this because 'test' just
automaticaly succeeds if no test frameworks are found. To guard against
regression, I had to ensure that 'test' failed for every strategy if a
bad test file was present.
This commit is contained in:
Ethan Atkins
2019-05-30 17:30:14 -07:00
parent cda4713f89
commit cf73bbbafc
3 changed files with 16 additions and 4 deletions
@@ -132,7 +132,6 @@ private[sbt] object ClassLoaders {
case _: AllLibraryJars => true
case _ => false
}
val allDependenciesSet = allDependencies.toSet
val scalaLibraryLayer = layer(si.libraryJars, interfaceLoader, cache, resources, tmp)
val cpFiles = fullCP.map(_._1)
@@ -148,7 +147,10 @@ private[sbt] object ClassLoaders {
else resourceLayer
// layer 4
val dynamicClasspath = cpFiles.filterNot(allDependenciesSet ++ si.libraryJars)
val filteredSet =
if (layerDependencies) allDependencies.toSet ++ si.libraryJars
else Set(si.libraryJars: _*)
val dynamicClasspath = cpFiles.filterNot(filteredSet)
new LayeredClassLoader(dynamicClasspath, dependencyLayer, resources, tmp)
}
ClasspathUtilities.filterByClasspath(cpFiles, raw)
@@ -1,3 +1,5 @@
> set Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
-> run
> set Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
@@ -1,3 +1,5 @@
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
> test
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
@@ -8,8 +10,14 @@
> test
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
$ copy-file changes/bad.scala src/test/scala/sbt/ScalatestTest.scala
-> test
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
-> test
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
-> test