forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix com-lihaoyi#370 Use ExtClassLoader instead of null as parent
- Loading branch information
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
scalalib/test/resources/classloader-test/test/src/ClassLoaderTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package mill.scalalib | ||
|
||
import utest._ | ||
|
||
object ClassLoaderTests extends TestSuite { | ||
try { | ||
getClass().getClassLoader().loadClass("com.sun.nio.zipfs.ZipFileSystemProvider") | ||
} catch { | ||
case _: ClassNotFoundException if !System.getProperty("java.specification.version").startsWith("1.") => | ||
// Don't fail on Java 9+ | ||
} | ||
val tests = Tests {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mill.scalalib | ||
|
||
import mill.{Agg, T} | ||
|
||
import scala.util.Success | ||
import mill.testrunner.TestRunner.TestArgs | ||
import mill.util.{TestEvaluator, TestUtil} | ||
import org.scalacheck.Prop.forAll | ||
import utest._ | ||
import utest.framework.TestPath | ||
|
||
object TestClassLoaderTests extends TestSuite { | ||
object testclassloader extends TestUtil.BaseModule with ScalaModule { | ||
override def millSourcePath = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.') | ||
|
||
def scalaVersion = sys.props.getOrElse("TEST_SCALA_2_12_VERSION", ???) | ||
|
||
object test extends super.Tests with TestModule.Utest { | ||
override def ivyDeps = T { | ||
super.ivyDeps() ++ Agg( | ||
ivy"com.lihaoyi::utest:${sys.props.getOrElse("TEST_UTEST_VERSION", ???)}" | ||
) | ||
} | ||
} | ||
} | ||
|
||
val resourcePath = os.pwd / "scalalib" / "test" / "resources" / "classloader-test" | ||
|
||
def workspaceTest[T]( | ||
m: TestUtil.BaseModule, | ||
resourcePath: os.Path = resourcePath | ||
)(t: TestEvaluator => T)( | ||
implicit tp: TestPath | ||
): T = { | ||
val eval = new TestEvaluator(m) | ||
os.remove.all(m.millSourcePath) | ||
os.remove.all(eval.outPath) | ||
os.makeDir.all(m.millSourcePath / os.up) | ||
os.copy(resourcePath, m.millSourcePath) | ||
t(eval) | ||
} | ||
|
||
override def tests: Tests = Tests { | ||
test("classloader can load com.sun.* on Java 8") { | ||
workspaceTest(testclassloader) { eval => | ||
assert(eval.apply(testclassloader.test.test()).isRight) | ||
} | ||
} | ||
} | ||
} |