diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-12 07:43:54 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-12 07:43:54 -0800 |
commit | de3f16918dc5b5af6cb8bf226f3aa80ef8879bba (patch) | |
tree | cb5c43ac45ef346c8e69bb18d3fef3271358e163 /scalaplugin | |
parent | d4334c43f1207d5bfc6039fc3d64486b1dc98115 (diff) | |
download | mill-de3f16918dc5b5af6cb8bf226f3aa80ef8879bba.tar.gz mill-de3f16918dc5b5af6cb8bf226f3aa80ef8879bba.tar.bz2 mill-de3f16918dc5b5af6cb8bf226f3aa80ef8879bba.zip |
Make sure Mill classpath doesn't leak into test classloaders, except for specific white-listed classes (e.g. `sbt-test-interface`)
Diffstat (limited to 'scalaplugin')
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala index 1fc4e32e..93721e8f 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala @@ -39,7 +39,16 @@ object TestRunner { def apply(frameworkName: String, entireClasspath: Seq[Path], testClassfilePath: Seq[Path]): Unit = { - val cl = new URLClassLoader(entireClasspath.map(_.toIO.toURI.toURL).toArray, getClass.getClassLoader) + val outerClassLoader = getClass.getClassLoader + val cl = new URLClassLoader(entireClasspath.map(_.toIO.toURI.toURL).toArray){ + override def findClass(name: String) = { + if (name.startsWith("sbt.testing.")){ + outerClassLoader.loadClass(name) + }else{ + super.findClass(name) + } + } + } val framework = cl.loadClass(frameworkName) .newInstance() |